-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to an es6 module system where possible, using webpack to package files. #1578
Conversation
This looks great. We should be able to move tons of stuff to modules with this change. Are you thinking of bundling in addition to minification? If webpack bundled stuff for us, it would remove a lot of pain points (especially ongoing troubles with Node not supporting es modules correctly. Though, maybe the newer versions of node work better?). |
Not sure yet, I was mainly thinking about bundling rather than minification. Though I'd like to play around a bit first and see what we need to do vs might like to do. |
8aa5d5d
to
620586d
Compare
Big update here, this switches to webpack for bundling the files for most of the various pages. I think the add-on is working if it is built, though tests are still failing - I haven't yet worked out what is the right magic for webpack + jest + babel. Also probably need to do some more re-arranging of some of the files, so that we can make the build script simpler (and also do things like remove redundant files/modules, and stop manually copying things). |
I haven't ever set up babel with jest directly (I use create-react-app), but maybe this is what we're looking for https://www.npmjs.com/package/babel-jest ? I think all the file extensions should be removed from imports, since it will likely get confusing about whether we're importing |
Thanks, I'll take a look either later or tomorrow. |
I think that it is all working now with the latest updates. I'll go through the diffs again tomorrow or over the weekend and then probably merge. |
… files. This switches over to using es6 for most of stub.html. Some parts still require the legacy style imports and these are contained within stubGlobals.js. Webpack is used to package the javascript and support files, avoiding the need to manually copy vendor files.
I think I've figured out a reasonable way to make most of the stub files be modules. The basic idea is to move the import code into a separate file that's loaded as a normal javascript file (stubGlobals.js) - with defined globals. The rest of the files can then be loaded as modules, and access the globals as needed. I've made stub.js, reducer.js and reducer-deps.js into modules so far.
I'm thinking we can possibly switch to minifying all of the includes as well, which would mean that we could hopefully include react/redux/etc as normal imports as well.
Whilst this isn't 100% perfect, I think it should help with getting most of this running as modules, and making the test hacks simpler or non-existent.
@siefkenj I'm going to review your PR next (and get that landed), and then continue work on this. Hence there may be a few big changes coming. In the meantime, if you see any big issues in the idea here, let me know.