-
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
Turbopack: more static typeof replacements for ESM #69914
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
console.log("typeof require", typeof require) | ||
console.log("typeof import.meta", typeof import.meta) | ||
// CJS, should be `object` | ||
console.log("typeof module", typeof module) | ||
console.log("typeof exports", typeof exports) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import './dep.js' | ||
|
||
console.log("typeof require", typeof require) | ||
console.log("typeof import.meta", typeof import.meta) | ||
// ESM, should be `undefined` | ||
console.log("typeof module", typeof module) | ||
console.log("typeof exports", typeof exports) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
console.log("typeof require", typeof require) | ||
console.log("typeof import.meta", typeof import.meta) | ||
// ESM, should be `undefined` | ||
console.log("typeof module", typeof module) | ||
console.log("typeof exports", typeof exports) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import "./cjs.js" | ||
import "./esm-automatic.js" | ||
import "./esm-specified.mjs" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
warning - [analysis] [project]/turbopack/crates/turbopack-tests/tests/snapshot/comptime/typeof/input/esm-specified.mjs Specified module format (EcmaScript Modules) is not matching the module format of the source code (CommonJs) | ||
The EcmaScript module format was specified in the package.json that is affecting this source file or by using an special extension, but it looks like that CommonJs syntax is used in the source code. | ||
Exports made by CommonJs syntax will lead to a runtime error, since the module is in EcmaScript mode. Either change the "type" field in the package.json or replace CommonJs syntax with EcmaScript import/export syntax in the source file. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this logic out of the callsite in
lib.rs
andreferences/mod.rs
seems like a very good cleanup 👍, otherwise this API seems like a very subtle footgun (if you don't checkSpecifiedModuleType
, it will work 90% of the time until it doesn't).