-
Notifications
You must be signed in to change notification settings - Fork 46
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
front: switch package type to module #10671
Conversation
e5c2185
to
3f73aa6
Compare
fb765b4
to
aaf9e0f
Compare
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.
Lgtm and tested (didn't launch the e2e tests)
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.
require() cannot be used with packages marked as modules. We want to switch osrd to modules. Signed-off-by: Simon Ser <contact@emersion.fr>
We'll soon change the default to ESM. rtk-query requires config files to be CJS: reduxjs/redux-toolkit#2437 (comment) Signed-off-by: Simon Ser <contact@emersion.fr>
JSON imports cause issues with ESM. Signed-off-by: Simon Ser <contact@emersion.fr>
When directly importing a file from a CommonJS package, the file extension needs to be specified: https://nodejs.org/api/esm.html#esm_mandatory_file_extensions Signed-off-by: Simon Ser <contact@emersion.fr>
pdf-parse is not maintained anymore and is causing issues with newer standards: https://gitlab.com/autokent/pdf-parse/-/issues/38 Instead, directly use the official pdf.js package. We need to fiddle with transform[5] which indicates when a line break happens: https://stackoverflow.com/questions/54645206/pdfjs-get-raw-text-from-pdf-with-correct-newline-withespace The legacy build needs to be used in Nodejs environments: https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support Signed-off-by: Simon Ser <contact@emersion.fr>
Modules are the standard way to handle JavaScript imports. osrd-ui already uses modules everywhere, but osrd is lagging behind. Modernize our configuration to use ECMAScript Modules instead of legacy CommonJS. Signed-off-by: Simon Ser <contact@emersion.fr>
We now use ESM everywhere, we don't need to resolve CommonJS nor AMD anymore. The rule is enabled by default by import/recommended, so dropping the line just uses the defaults instead of custom options. Signed-off-by: Simon Ser <contact@emersion.fr>
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.
LGTM ✅
See individual commits.
Modules are the standard way to handle JavaScript imports. osrd-ui already uses modules everywhere, but osrd is lagging behind.
Modernize our configuration to use ECMAScript Modules instead of legacy CommonJS.