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

the result of resolve tslib is diffrent from webpack #2173

Closed
underfin opened this issue Apr 11, 2022 · 2 comments
Closed

the result of resolve tslib is diffrent from webpack #2173

underfin opened this issue Apr 11, 2022 · 2 comments

Comments

@underfin
Copy link

underfin commented Apr 11, 2022

Description

The tslib package.json condition exports has a module filed.

"exports": {
      ".": {
          "module": "./tslib.es6.js",
          "import": "./modules/index.js",
          "default": "./tslib.js"
      },
      "./": "./"
  }

It can be webpack used and keep bundle result correctly, but esbuild is not (esbuild use import).

Reproduction

https://github.com/underfin/bug-reporter/tree/master/esbuild-tslib

  • pnpm i && npm run build

esbuild output https://github.com/underfin/bug-reporter/blob/master/esbuild-tslib/esbuild-output.js#L454

webpack output https://github.com/underfin/bug-reporter/blob/master/esbuild-tslib/webpack-output/main.js#L23

Maybe helpers issue

@hyrious
Copy link

hyrious commented Apr 11, 2022

module is not a formal field of node's exports, see Conditional exports in the doc. esbuild won't support that.

I'll suggest that they use this pattern to force bundling the same file when targetting browser:

"exports": {
  ".": {
    "node": {
      "import": "./modules/index.js",
      "require": "./tslib.js"
    },
    "default": "./tslib.es6.js"
  }
}

On the other hand, you can write a plugin to force resolving to the file you want.

@evanw
Copy link
Owner

evanw commented Apr 11, 2022

The name module is meaningless here. The standard doesn’t specify any special behavior for it. You can give it meaning using --conditions=module if you’d like: https://esbuild.github.io/api/#conditions.

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

No branches or pull requests

3 participants