-
Notifications
You must be signed in to change notification settings - Fork 343
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
feat: convert web-ext package into a nodejs native ES module #2405
Conversation
82d5d16
to
f53fc94
Compare
e299a16
to
4797737
Compare
Codecov Report
@@ Coverage Diff @@
## master #2405 +/- ##
==========================================
- Coverage 99.88% 0 -99.89%
==========================================
Files 32 0 -32
Lines 1701 0 -1701
==========================================
- Hits 1699 0 -1699
+ Misses 2 0 -2 Continue to review full report at Codecov.
|
6830b98
to
b983aa1
Compare
57878a3
to
a5f9590
Compare
@willdurand This PR does now cover everything that we discussed earlier today, in particular:
Then I also compared the package size as agreed, it is slightly bigger but imho not that much to be concerned about the difference:
This is now ready for another review pass from your perspective. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+wc, thanks
8fc3ffb
to
9d86ed5
Compare
- Changes to npm scripts to work as ESM modules (and replaced webpack with babel-cli as build step) - Add small custom node module loader (tests/babel-loader.js) to transpile on the fly (used to make mocha able to load tests modules using flowtype syntaxes) - Re-export custom node module loader exports provided by testdouble / quibble to be able to mock ES modules in some tests (used as part of workaround for sinon.stub limitations on stubbing ES modules) - Added babel-plugin-transform-inline-environment-variables to interpolate environment variable during babel transpiling (replaces webpack interpolated WEBEXT_BUILD_ENV global) - converted build scripts and fake firefox and amo scripts to ES modules - fixed sign-addon import when it is loaded using the nodejs native ES module loader (caught by functional tests)
@willdurand Thanks a lot for all the support and help reviewing this PR ❤️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see this change!
const absolutePackageDir = path.join( | ||
path.dirname(fileURLToPath(import.meta.url)), | ||
'..' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that that the new way would be to use URL instead of path, something like fileURLToPath(new URL('..', import.meta.url))
, and you'd have the full path.
Fixes #2311
Fixes #1306
This pull requests goal is to convert web-ext package into a nodejs native ES module.
Changes to npm scripts to work as ESM modules (and replaced webpack with babel-cli as build step)
Add small custom node module loader (tests/babel-loader.js) to transpile on the fly (used to make mocha able to load tests modules using flowtype syntaxes)
Re-export custom node module loader exports provided by testdouble / quibble to be able to mock ES modules in some tests (used as part of workaround for sinon.stub limitations on stubbing ES modules)
Added babel-plugin-transform-inline-environment-variables to interpolate environment variable during babel transpiling (replaces webpack interpolated WEBEXT_BUILD_ENV global)
converted build scripts and fake firefox and amo scripts to ES modules
fixed sign-addon import when it is loaded using the nodejs native ES module loader (caught by functional tests)
package size comparison
The new package size is 165 kB (unpacked 699 kB) vs old package size 103 kB (unpacked 442 kB).
TODO list
other notes
NOTE: the following jscodeshift transform script has been created and used to aid the conversion to ES modules that loads successfully while using the nodejs native ES module loader: