-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Some "exports" are not transpiled to "__webpack_exports__" and cause "ReferenceError: exports is not defined" #59603
Comments
The javascript code of "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
BaseClass: function() {
return BaseClass;
},
BaseClass2: function() {
return BaseClass2;
}
});
class BaseClass {
#a;
#b;
constructor(){
this.#b = 2;
}
get a() {
if (this.#a === undefined) {
this.#a = 1;
}
return this.#a;
}
get b() {
return this.#b;
}
}
class BaseClass2 {
#a;
#b;
constructor(){
this.#b = 2;
}
get a() {
if (this.#a === undefined) {
this.#a = 1;
}
return this.#a;
}
get b() {
return this.#b;
}
} @kdy1 Would you please take a look? Is it a next-swc bug? |
I cannot reproduce.
|
Please verify that your issue can be recreated with Why was this issue marked with the
|
Okay I reproduced it. |
I got it. You configured |
I uploaded the fix at https://github.com/kdy1/next-repro-59603 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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. |
Link to the code that reproduces this issue
https://github.com/yf-yang/next-14-exports-bug
To Reproduce
Current vs. Expected behavior
The site got an error: "ReferenceError: exports is not defined"
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64 Binaries: Node: 20.9.0 npm: 10.1.0 Yarn: 1.22.19 pnpm: 8.10.0 Relevant Packages: next: 14.0.5-canary.12 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
SWC transpilation
Additional context
I've located the bug:
in
myapp/.next/static/chunks/app/page.js
, the generated code of(app-pages-browser)/../dep/build/base.js
is:Here,
_export(exports, ...)
should be transpiled to_export(__webpack_exports__, ...)
, but it fails to do so.It seems it only happen when those
_swc_helpers_class_private_field_xxxxxx
exist, I am not sure that's a bundler bug or swc bug, tag it as swc bug for now.The bug does not appear in next 13.5.4
The text was updated successfully, but these errors were encountered: