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

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

Open
SyraTi opened this issue Sep 8, 2023 · 2 comments
Open

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

SyraTi opened this issue Sep 8, 2023 · 2 comments

Comments

@SyraTi
Copy link

SyraTi commented Sep 8, 2023

  • Rollup Plugin Name: node-resolve
  • Rollup Plugin Version: 15.2.1
  • Rollup Version: 3.29.0
  • Operating System (or Browser): MacOS Monterey
  • Node Version: 18
  • Link to reproduction (⚠️ read below): https://github.com/SyraTi/node-resolve-typeorm-demo
  • How to reproduce: git clone & npm run build

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:
#1548
#1549
and tried allowExportsFolderMapping option but not working.

@tada5hi
Copy link
Member

tada5hi commented Sep 15, 2023

@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

@stale stale bot added the x⁷ ⋅ stale label Dec 15, 2023
@jens1101
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants