-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for esm module resolution algorithm in node
This brings some changes that will make the packages fully compliant by default with the node's esm module resolution algorithm. This will make the packages usable out-of-the-box for node applications without the need for transpilation. This required the following changes: - Changing `tsconfig`'s `module` and `moduleresolution` settings to `nodenext`. - Changing all file imports to be fully specified, i.e., add the file extension to them. - Changing all folder imports to file imports that target `index.js` files. - Adding dependencies that are esm compliant like lodash-es and crypto-es. - Changing files in `tests` folder to use `mts` extension to make it compliant with typescript while not requiring change the root package.json `type` to `module` which could break tools that are not ESM-compatible. - Adding tweaks to `jest.config.js` to make it work with imports that have file extensions. - Upgrading some dependencies to a version that is compatible with ESM: axios (to v1.3.1), yup (to v1.0.2). - Adding @typescript-eslint/no-restricted-imports lint rule to avoid using named imports from packages that are not exporting in a way that node can make them available when being imported. Also the following changes were introduced: - A new npm script `dev:link` was added which will link the built packages with `yarn link`. This will enable the testing of new changes in the packages on an application without waiting for a release. The `prebuild` command was removed as well since it would remove the `dist` folder which contained the package.json file necessary for linking. A `dev:unlink` script was also added to unlink the packages. - Also added a `build:watch` script which will speed up the compilation when you linked the packages by using the command `dev:link`. - The `release:build` script was also renamed to just `build` to be similar to other projects. - I took the opportunity to change the `browserslist` configuration to `defaults or node 14` to avoid having the packages include transformations where not necessary. This bumped the minimum node version to 14. - React dependency in `blackout-react` package was also bumped to v18 due to a bug in React which would not allow the imports to `react/jsx-runtime` to resolve and those imports are added without extension by @babel/preset-react. BREAKING CHANGE: Now the package is fully ESM-compliant which means it is not necessary anymore to run in node with `--experimental-specifier-resolution=node` to make it work. For web projects, it might be necessary to tweak some bundler settings to make it work, depending on the bundler/framework used. `lodash-es` and `crypto-es` packages replaced `lodash` and `crypto-js` respectively, so you might need to install these peer dependencies if your project does not use them. axios peer dependency version is now `1.3.1` which should be installed as well. In our tests, no breaking changes were found by using this version of axios. Node version was bumped to 14 so if you need to use an older version you will need to transpile the code. React 18 is now the peer dependency of `@farfetch/blackout-react` package but if you are transpiling the code you can use the package safely in previous 16 and 17 versions.
- Loading branch information
1 parent
4e2cc95
commit 466c49c
Showing
3,045 changed files
with
13,284 additions
and
13,534 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,2 @@ | ||
node 14 | ||
and_chr 91 | ||
and_ff 89 | ||
and_qq 10.4 | ||
and_uc 12.12 | ||
android 91 | ||
baidu 7.12 | ||
chrome 90 | ||
edge 91 | ||
firefox 78 | ||
ios_saf 12.2 | ||
kaios 2.5 | ||
op_mini all | ||
op_mob 76 | ||
opera 76 | ||
safari 14 | ||
samsung 13.0 | ||
defaults | ||
node 14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import merge from 'lodash/merge'; | ||
import { merge } from 'lodash-es'; | ||
|
||
type Data = Record<string, unknown>; | ||
|
||
|
Oops, something went wrong.