Skip to content
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

Bump os-locale (add support for ESM dependencies) #5415

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Aug 23, 2024

os-locale v6 has huge savings

v5

Screenshot 7

v6

Screenshot 6

@fregante fregante mentioned this pull request Aug 23, 2024
@fregante fregante marked this pull request as draft August 23, 2024 09:02
@fregante fregante marked this pull request as ready for review August 23, 2024 12:20
babel.config.json Outdated Show resolved Hide resolved
@@ -27,7 +28,7 @@ module.exports = {
'^.+\\.js$': 'babel-jest',
'^.+\\.txt$': '<rootDir>/tests/jest-raw-loader.js',
},
transformIgnorePatterns: ['<rootDir>/node_modules/'],
transformIgnorePatterns: ['<rootDir>/node_modules/(?!os-locale)'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standard config for ESM packages

// and make the import silently asynchronous. In most cases this breaks the import.
const dependenciesToBundle = [
'os-locale', // Used exclusively in sync functions
];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As expected, there's "no way" to require a ESM package synchronously. This is not a webpack/config issue. The only way for this to work is to turn addons-linter into an type=module package.

So this is the alternative: do not keep os-locale as an external dependency, so that node does not try to require it at runtime.

module.exports = {
// Set the webpack4 mode 'none' for compatibility with the behavior of the
// webpack3 bundling step.
mode: 'none',
entry: {
'addons-linter': './src/main.js',
},
target: 'node',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack defaults to browserlist, if set. We have it already and it's set to node 16. This enables ESM support

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.77%. Comparing base (348829c) to head (b4543d5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5415   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files          51       51           
  Lines        2855     2855           
  Branches      867      867           
=======================================
  Hits         2820     2820           
  Misses         35       35           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fregante fregante mentioned this pull request Aug 23, 2024
16 tasks
@fregante fregante changed the title Bump os-locale Bump os-locale (add support for ESM dependencies) Aug 23, 2024
@fregante
Copy link
Contributor Author

Ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant