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

feat: add an option to configure which file processed by esbuild #1455

Merged
merged 1 commit into from
May 8, 2022
Merged

feat: add an option to configure which file processed by esbuild #1455

merged 1 commit into from
May 8, 2022

Conversation

ahnpnl
Copy link
Collaborator

@ahnpnl ahnpnl commented May 8, 2022

Summary

Introduce new option in Jest globals called processWithEsbuild which accepts glob patterns to allow users to configure which files to be transformed by esbuild.

Different NPM packages have different ways of distributing ESM codes. Some can be processed with esbuild and Jest is happy with it, some Jest isn't happy. When Jest isn't happy with the output processed by esbuild, we need to fall back to use TypeScript API, which almost guarantees 100% for Jest.

Fixes #1413
Fixes #1437

Test plan

Green CI

Does this PR introduce a breaking change?

  • Yes
  • No

Previously, we always checked file extension .mjs and any files from node_modules excluding tslib to be processed with esbuild. With the new option processWithEsbuild, now we limit to only .mjs files. Files like lodash-es default isn't processed by esbuild. If you wish to use esbuild to process such files, please configure in your Jest config like

// jest.config.js
module.exports = {
    //...
    globals: {
         ngJest: {
              processWithEsbuild: ['**/node_modules/lodash-es/*.js],
         }
    }
}

Other information

N.A.

@ahnpnl ahnpnl added the 💣 Breaking Changes Includes a breaking change and should probably wait until we're preparing for the release of a major label May 8, 2022
BREAKING CHANGE
Previously, we always checked file extension `.mjs` and any files from `node_modules` excluding `tslib` to be processed with `esbuild`. With the new option `processWithEsbuild`, now we put default all `.mjs` files to be processed by `esbuild`.

Files like `lodash-es` default isn't processed by `esbuild`. If you wish to use `esbuild` to process such files, please configure in your Jest config like
```
// jest.config.js
module.exports = {
    //...
    globals: {
         ngJest: {
              processWithEsbuild: ['**/node_modules/lodash-es/*.js],
         }
    }
}
```
@ahnpnl ahnpnl marked this pull request as ready for review May 8, 2022 15:41
@ahnpnl ahnpnl merged commit b58d089 into thymikee:main May 8, 2022
@ahnpnl ahnpnl deleted the feat/process-with-esbuild branch May 8, 2022 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💣 Breaking Changes Includes a breaking change and should probably wait until we're preparing for the release of a major
Projects
None yet
1 participant