-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Cannot import from .mjs
file with locally scoped module.exports =
code.
#57962
Labels
bug
Issue was opened via the bug report template.
locked
Module Resolution
Module resolution (CJS / ESM, module resolving)
Comments
tmeasday
added a commit
to storybookjs/storybook
that referenced
this issue
Nov 6, 2023
To workaround vercel/next.js#57962 cc @ndelangen. Not sure we want to merge this but it gets us through the demo for now.
This was referenced Nov 17, 2023
looks like there's a potential fix here |
Reproduction of a possibly related bug: #57784 (comment) |
shilman
pushed a commit
to storybookjs/storybook
that referenced
this issue
Dec 2, 2023
To workaround vercel/next.js#57962 cc @ndelangen. Not sure we want to merge this but it gets us through the demo for now.
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
huozhi
added
the
Module Resolution
Module resolution (CJS / ESM, module resolving)
label
Jan 2, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
bug
Issue was opened via the bug report template.
locked
Module Resolution
Module resolution (CJS / ESM, module resolving)
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/modern-currying-yz577d
In
.mjs
file:To Reproduce
Attempted import error: 'bar' is not exported from './file.mjs' (imported as 'bar').
module.exports =
linefile.js
(fromfile.mjs
)Current vs. Expected behavior
I would expect that the compiler would ignore
module.exports = {}
wheremodule
is a local variable.The above code is similar to code generated by esbuild:
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 Binaries: Node: 18.18.2 npm: 9.8.1 Yarn: 1.22.18 pnpm: 8.6.2 Relevant Packages: next: 14.0.2-canary.8 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 4.9.4 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Additional context
I reproduced locally on canary but the code sandbox repro template is fixed to node 16 so I wasn't sure how to upgrade. Still the behaviour seems the same.
The code above is included in a file when dependencies are prebundled, e.g. with a tool like tsup. This symptom happens for the Storybook packages, which use tsup and generate
.mjs
files.I notice the error is the same as #47945 and #48091. There isn't really enough context on those issues to say if it's the same problem.
The text was updated successfully, but these errors were encountered: