I have SafenetworkJS working with Node 8 and have just begun to package it for web using
webpack, but am hitting a problem at runtime for which the online solutions seem to be to use
export default ... instead of
module.exports = ... (i.e. adopting ES6 style module export syntax). But looking at Node v8 through v11 it does not support this (only
require() for import and
module.exports for export). I’m a bit confused because even this comprehensive Node ES compatibility table doesn’t mention
export so I think I might be misunderstanding something here. Beware: possible n00b errors!
Initial research suggests one solution to that would be to use a transpiler like
rollup to generate a CommonJS build from ES6 sources. This might be a good idea because I can use more up to date features in my code, but adds a new build step that I’ve not needed so far while developing for nodejs (ie SAFE Drive / SAFE CLI).
What do people recommend?
Also, if I build a CommonJS library, how to I get my nodejs app to pick that up rather than the source - does it look for a particular subfolder?