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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use dynamic imports when context is Node #9375

Open
liamqma opened this issue Nov 10, 2023 · 0 comments 路 May be fixed by #9376
Open

Cannot use dynamic imports when context is Node #9375

liamqma opened this issue Nov 10, 2023 · 0 comments 路 May be fixed by #9376
Labels

Comments

@liamqma
Copy link

liamqma commented Nov 10, 2023

馃悰 bug report

When the target's context is Node

  "targets": {
    "node": {
      "context": "node"
    }
  },

and use dynamic import

// index.js
import("./foo").then(foo => console.log(foo))
// foo.js
export const foo = "foo";

, then run

parcel watch index.js --no-cache --target node

The generated JS looks like

module.exports = Promise.resolve(require("./foo.da43fb97.js?" + Date.now())).then(()=>module.bundle.root("4Knu0"));

When node ./dist/index.js, it errors out

Error: Cannot find module './foo.da43fb97.js?1699650105056'

I've created a simple repo to reproduce this problem. In my real world app, foo.js is a node_module, so I cannot remove the dynamic require.

馃 Expected Behavior

I understand ?1699650105056 is to clear the module cache but node require doesn't seem to accept it.

馃槸 Current Behavior

Should be able to run node ./dist/index.js

馃捇 Code Sample

https://github.com/liamqma/reproduce-parcel-bug

馃實 Your Environment

Software Version(s)
Parcel ^2.10.2
Node v16.14.0
Yarn 1.22.19
Operating System macOS
@github-actions github-actions bot added the Stale Inactive issues label May 10, 2024
@parcel-bundler parcel-bundler deleted a comment from github-actions bot May 14, 2024
@mischnic mischnic removed the Stale Inactive issues label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants