rollup / plugins

🍣 The one-stop shop for official Rollup plugins
MIT License
3.62k stars 581 forks source link

[node-resolve] Can not resolve exports of "typeorm" #1579

Open SyraTi opened 1 year ago

SyraTi commented 1 year ago

Expected Behavior

typeorm be packed into bundle

Actual Behavior

typeorm cannot be resolved:

(!) Plugin node-resolve: Could not resolve import "typeorm" in /Users/syra_ti/Documents/projects/gensou-studio/rollup-with-typeorm/src/entities/subscription.ts using exports defined in /Users/syra_ti/Documents/projects/gensou-studio/rollup-with-typeorm/node_modules/typeorm/package.json.
(!) Plugin node-resolve: Could not resolve import "typeorm" in /Users/syra_ti/Documents/projects/gensou-studio/rollup-with-typeorm/src/datasource.ts using exports defined in /Users/syra_ti/Documents/projects/gensou-studio/rollup-with-typeorm/node_modules/typeorm/package.json.
(!) Unresolved dependencies
https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
typeorm (imported by "src/entities/subscription.ts" and "src/datasource.ts")

Additional Information

I guess the problem is about "exports" field resolving in typeorm/package.json. I've read some related issue&pr below: https://github.com/rollup/plugins/issues/1548 https://github.com/rollup/plugins/pull/1549 and tried allowExportsFolderMapping option but not working.

tada5hi commented 1 year ago

@SyraTi Really strange behaviour. I have also used rollup for a typeorm extension, but not the typescript plugin and it works there. Maybe you can get some useful information from the repo. https://github.com/tada5hi/typeorm-extension

jens1101 commented 5 months ago

I have recently come across this same issue. I solved this by setting the exportConditions option to ["node"]. For example:

  plugins: [
    // ...
    nodeResolve({
      exportConditions: ["node"],
    }),
  ],