First thing I’ve noticed is uno build now runs npm install if it finds package.json file in project folder.
I hoped that means we can now NPM modules straight away in ES6 code (as clearly there’s transpilation going on), but looks that’s not the case - unless I am missing some trick?
Is having webpack/rollup necessary to use modules from NPM?
Hi! That unfortunately does not mean we support using NPM modules directly in Fuse. You can use something like webpack, or perhaps give nfuse a shot. Please also note that a lot of packages depend on being run in a browser/node.js environment, and will not necessarily work with Fuse.
OK, no worries - I already had some success with webpack, so that’s not a major deal, but there’s one more question in that case!
uno build automatically runs npm install as a part of build process, but is there anything else it could run automatically, or do I have to hook into post-install somehow to execute webpack build?
Uno does unfortunately not support build scripts yet, but NPM does You can add a postinstall script to your package.json that will be run after every npm install, like this:
Once I added webpack setup in a TodoExample project (Fuse 1.6 demo), created functions.js file containing exported functions that make use of NPM modules (all vetted and adapted for Fuse - had it working in 1.5), I am now getting the following output when running uno build:
Now, I have no idea where these are coming from - none of the modules I am importing in my functions.js are using fsevents or any other module mentioned in output log (there’s mkdirp, user-home and webpack included). It looks like Babel transpiller launched by uno build tries to touch everything that’s in my node_modules folder?
@Maciek Szczesniak - this seems really cool. Would it be possible for you to provide a starter project with this set up on something like github? I am not very familiar with Webpack, but I’d love to be able to just ‘npm install --save’ js libraries into my fuse project (compatible ones of course).