Skip to content

Commit 0cbb5dd

Browse files
committed
Remove unrelated Turbopack formatting changes
1 parent 1348c90 commit 0cbb5dd

2 files changed

Lines changed: 77 additions & 90 deletions

File tree

  • turbopack/crates/turbopack-ecmascript/src

turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs

Lines changed: 61 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,10 @@ impl JsValue {
19721972
"Generator",
19731973
"A Generator or AsyncGenerator object: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator",
19741974
),
1975-
WellKnownObjectKind::GlobalObject => ("Object", "The global Object variable"),
1975+
WellKnownObjectKind::GlobalObject => (
1976+
"Object",
1977+
"The global Object variable",
1978+
),
19761979
WellKnownObjectKind::PathModule | WellKnownObjectKind::PathModuleDefault => (
19771980
"path",
19781981
"The Node.js path module: https://nodejs.org/api/path.html",
@@ -1981,8 +1984,7 @@ impl JsValue {
19811984
"fs",
19821985
"The Node.js fs module: https://nodejs.org/api/fs.html",
19831986
),
1984-
WellKnownObjectKind::FsExtraModule
1985-
| WellKnownObjectKind::FsExtraModuleDefault => (
1987+
WellKnownObjectKind::FsExtraModule | WellKnownObjectKind::FsExtraModuleDefault => (
19861988
"fs-extra",
19871989
"The Node.js fs-extra module: https://github.com/jprichardson/node-fs-extra",
19881990
),
@@ -1994,18 +1996,15 @@ impl JsValue {
19941996
"url",
19951997
"The Node.js url module: https://nodejs.org/api/url.html",
19961998
),
1997-
WellKnownObjectKind::ModuleModule
1998-
| WellKnownObjectKind::ModuleModuleDefault => (
1999+
WellKnownObjectKind::ModuleModule | WellKnownObjectKind::ModuleModuleDefault => (
19992000
"module",
20002001
"The Node.js `module` module: https://nodejs.org/api/module.html",
20012002
),
2002-
WellKnownObjectKind::WorkerThreadsModule
2003-
| WellKnownObjectKind::WorkerThreadsModuleDefault => (
2003+
WellKnownObjectKind::WorkerThreadsModule | WellKnownObjectKind::WorkerThreadsModuleDefault => (
20042004
"worker_threads",
20052005
"The Node.js `worker_threads` module: https://nodejs.org/api/worker_threads.html",
20062006
),
2007-
WellKnownObjectKind::ChildProcessModule
2008-
| WellKnownObjectKind::ChildProcessModuleDefault => (
2007+
WellKnownObjectKind::ChildProcessModule | WellKnownObjectKind::ChildProcessModuleDefault => (
20092008
"child_process",
20102009
"The Node.js child_process module: https://nodejs.org/api/child_process.html",
20112010
),
@@ -2031,22 +2030,28 @@ impl JsValue {
20312030
),
20322031
WellKnownObjectKind::NodeExpressApp => (
20332032
"express",
2034-
"The Node.js express package: https://github.com/expressjs/express",
2033+
"The Node.js express package: https://github.com/expressjs/express"
20352034
),
20362035
WellKnownObjectKind::NodeProtobufLoader => (
20372036
"@grpc/proto-loader",
2038-
"The Node.js @grpc/proto-loader package: https://github.com/grpc/grpc-node",
2037+
"The Node.js @grpc/proto-loader package: https://github.com/grpc/grpc-node"
20392038
),
20402039
WellKnownObjectKind::NodeBuffer => (
20412040
"Buffer",
2042-
"The Node.js Buffer object: https://nodejs.org/api/buffer.html#class-buffer",
2041+
"The Node.js Buffer object: https://nodejs.org/api/buffer.html#class-buffer"
20432042
),
20442043
WellKnownObjectKind::RequireCache => (
20452044
"require.cache",
2046-
"The CommonJS require.cache object: https://nodejs.org/api/modules.html#requirecache",
2045+
"The CommonJS require.cache object: https://nodejs.org/api/modules.html#requirecache"
2046+
),
2047+
WellKnownObjectKind::ImportMeta => (
2048+
"import.meta",
2049+
"The import.meta object"
2050+
),
2051+
WellKnownObjectKind::ModuleHot => (
2052+
"module.hot",
2053+
"The module.hot HMR API"
20472054
),
2048-
WellKnownObjectKind::ImportMeta => ("import.meta", "The import.meta object"),
2049-
WellKnownObjectKind::ModuleHot => ("module.hot", "The module.hot HMR API"),
20502055
};
20512056
if depth > 0 {
20522057
let i = hints.len();
@@ -2059,16 +2064,16 @@ impl JsValue {
20592064
JsValue::WellKnownFunction(func) => {
20602065
let (name, explainer) = match func {
20612066
WellKnownFunctionKind::ArrayFilter => (
2062-
"Array.prototype.filter".to_string(),
2063-
"The standard Array.prototype.filter method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter",
2067+
"Array.prototype.filter".to_string(),
2068+
"The standard Array.prototype.filter method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter"
20642069
),
20652070
WellKnownFunctionKind::ArrayForEach => (
2066-
"Array.prototype.forEach".to_string(),
2067-
"The standard Array.prototype.forEach method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach",
2071+
"Array.prototype.forEach".to_string(),
2072+
"The standard Array.prototype.forEach method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach"
20682073
),
20692074
WellKnownFunctionKind::ArrayMap => (
2070-
"Array.prototype.map".to_string(),
2071-
"The standard Array.prototype.map method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map",
2075+
"Array.prototype.map".to_string(),
2076+
"The standard Array.prototype.map method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map"
20722077
),
20732078
WellKnownFunctionKind::ObjectAssign => (
20742079
"Object.assign".to_string(),
@@ -2088,38 +2093,19 @@ impl JsValue {
20882093
),
20892094
WellKnownFunctionKind::Import => (
20902095
"import".to_string(),
2091-
"The dynamic import() method from the ESM specification: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports",
2096+
"The dynamic import() method from the ESM specification: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports"
20922097
),
2093-
WellKnownFunctionKind::Require => {
2094-
("require".to_string(), "The require method from CommonJS")
2095-
}
2098+
WellKnownFunctionKind::Require => ("require".to_string(), "The require method from CommonJS"),
20962099
WellKnownFunctionKind::RequireFrom(rel) => (
20972100
format!("createRequire('{rel}')"),
2098-
"The return value of Node.js module.createRequire: https://nodejs.org/api/module.html#modulecreaterequirefilename",
2099-
),
2100-
WellKnownFunctionKind::RequireResolve => (
2101-
"require.resolve".to_string(),
2102-
"The require.resolve method from CommonJS",
2101+
"The return value of Node.js module.createRequire: https://nodejs.org/api/module.html#modulecreaterequirefilename"
21032102
),
2104-
WellKnownFunctionKind::RequireContext => (
2105-
"require.context".to_string(),
2106-
"The require.context method from webpack",
2107-
),
2108-
WellKnownFunctionKind::RequireContextRequire(..) => (
2109-
"require.context(...)".to_string(),
2110-
"The require.context(...) method from webpack: https://webpack.js.org/api/module-methods/#requirecontext",
2111-
),
2112-
WellKnownFunctionKind::RequireContextRequireKeys(..) => (
2113-
"require.context(...).keys".to_string(),
2114-
"The require.context(...).keys method from webpack: https://webpack.js.org/guides/dependency-management/#requirecontext",
2115-
),
2116-
WellKnownFunctionKind::RequireContextRequireResolve(..) => (
2117-
"require.context(...).resolve".to_string(),
2118-
"The require.context(...).resolve method from webpack: https://webpack.js.org/guides/dependency-management/#requirecontext",
2119-
),
2120-
WellKnownFunctionKind::Define => {
2121-
("define".to_string(), "The define method from AMD")
2122-
}
2103+
WellKnownFunctionKind::RequireResolve => ("require.resolve".to_string(), "The require.resolve method from CommonJS"),
2104+
WellKnownFunctionKind::RequireContext => ("require.context".to_string(), "The require.context method from webpack"),
2105+
WellKnownFunctionKind::RequireContextRequire(..) => ("require.context(...)".to_string(), "The require.context(...) method from webpack: https://webpack.js.org/api/module-methods/#requirecontext"),
2106+
WellKnownFunctionKind::RequireContextRequireKeys(..) => ("require.context(...).keys".to_string(), "The require.context(...).keys method from webpack: https://webpack.js.org/guides/dependency-management/#requirecontext"),
2107+
WellKnownFunctionKind::RequireContextRequireResolve(..) => ("require.context(...).resolve".to_string(), "The require.context(...).resolve method from webpack: https://webpack.js.org/guides/dependency-management/#requirecontext"),
2108+
WellKnownFunctionKind::Define => ("define".to_string(), "The define method from AMD"),
21232109
WellKnownFunctionKind::FsReadMethod(name) => (
21242110
format!("fs.{name}"),
21252111
"A file reading method from the Node.js fs module: https://nodejs.org/api/fs.html",
@@ -2166,63 +2152,63 @@ impl JsValue {
21662152
),
21672153
WellKnownFunctionKind::NodeGypBuild => (
21682154
"node-gyp-build".to_string(),
2169-
"The Node.js node-gyp-build module: https://github.com/prebuild/node-gyp-build",
2155+
"The Node.js node-gyp-build module: https://github.com/prebuild/node-gyp-build"
21702156
),
21712157
WellKnownFunctionKind::NodeBindings => (
21722158
"bindings".to_string(),
2173-
"The Node.js bindings module: https://github.com/TooTallNate/node-bindings",
2159+
"The Node.js bindings module: https://github.com/TooTallNate/node-bindings"
21742160
),
21752161
WellKnownFunctionKind::NodeExpress => (
21762162
"express".to_string(),
2177-
"require('express')() : https://github.com/expressjs/express",
2163+
"require('express')() : https://github.com/expressjs/express"
21782164
),
21792165
WellKnownFunctionKind::NodeExpressSet => (
21802166
"set".to_string(),
2181-
"require('express')().set('view engine', 'jade') https://github.com/expressjs/express",
2167+
"require('express')().set('view engine', 'jade') https://github.com/expressjs/express"
21822168
),
21832169
WellKnownFunctionKind::NodeStrongGlobalize => (
2184-
"SetRootDir".to_string(),
2185-
"require('strong-globalize')() https://github.com/strongloop/strong-globalize",
2170+
"SetRootDir".to_string(),
2171+
"require('strong-globalize')() https://github.com/strongloop/strong-globalize"
21862172
),
21872173
WellKnownFunctionKind::NodeStrongGlobalizeSetRootDir => (
2188-
"SetRootDir".to_string(),
2189-
"require('strong-globalize').SetRootDir(__dirname) https://github.com/strongloop/strong-globalize",
2174+
"SetRootDir".to_string(),
2175+
"require('strong-globalize').SetRootDir(__dirname) https://github.com/strongloop/strong-globalize"
21902176
),
21912177
WellKnownFunctionKind::NodeResolveFrom => (
2192-
"resolveFrom".to_string(),
2193-
"require('resolve-from')(__dirname, 'node-gyp/bin/node-gyp') https://github.com/sindresorhus/resolve-from",
2178+
"resolveFrom".to_string(),
2179+
"require('resolve-from')(__dirname, 'node-gyp/bin/node-gyp') https://github.com/sindresorhus/resolve-from"
21942180
),
21952181
WellKnownFunctionKind::NodeProtobufLoad => (
2196-
"load/loadSync".to_string(),
2197-
"require('@grpc/proto-loader').load(filepath, { includeDirs: [root] }) https://github.com/grpc/grpc-node",
2182+
"load/loadSync".to_string(),
2183+
"require('@grpc/proto-loader').load(filepath, { includeDirs: [root] }) https://github.com/grpc/grpc-node"
21982184
),
21992185
WellKnownFunctionKind::NodeWorkerConstructor => (
2200-
"Worker".to_string(),
2201-
"The Node.js worker_threads Worker constructor: https://nodejs.org/api/worker_threads.html#worker_threads_class_worker",
2186+
"Worker".to_string(),
2187+
"The Node.js worker_threads Worker constructor: https://nodejs.org/api/worker_threads.html#worker_threads_class_worker"
22022188
),
22032189
WellKnownFunctionKind::WorkerConstructor => (
2204-
"Worker".to_string(),
2205-
"The standard Worker constructor: https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker",
2190+
"Worker".to_string(),
2191+
"The standard Worker constructor: https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker"
22062192
),
22072193
WellKnownFunctionKind::SharedWorkerConstructor => (
2208-
"SharedWorker".to_string(),
2209-
"The standard SharedWorker constructor: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/SharedWorker",
2194+
"SharedWorker".to_string(),
2195+
"The standard SharedWorker constructor: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/SharedWorker"
22102196
),
22112197
WellKnownFunctionKind::URLConstructor => (
2212-
"URL".to_string(),
2213-
"The standard URL constructor: https://developer.mozilla.org/en-US/docs/Web/API/URL/URL",
2198+
"URL".to_string(),
2199+
"The standard URL constructor: https://developer.mozilla.org/en-US/docs/Web/API/URL/URL"
22142200
),
22152201
WellKnownFunctionKind::ModuleHotAccept => (
2216-
"module.hot.accept".to_string(),
2217-
"The module.hot.accept HMR API: https://webpack.js.org/api/hot-module-replacement/#accept",
2202+
"module.hot.accept".to_string(),
2203+
"The module.hot.accept HMR API: https://webpack.js.org/api/hot-module-replacement/#accept"
22182204
),
22192205
WellKnownFunctionKind::ModuleHotDecline => (
2220-
"module.hot.decline".to_string(),
2221-
"The module.hot.decline HMR API: https://webpack.js.org/api/hot-module-replacement/#decline",
2206+
"module.hot.decline".to_string(),
2207+
"The module.hot.decline HMR API: https://webpack.js.org/api/hot-module-replacement/#decline"
22222208
),
22232209
WellKnownFunctionKind::ImportMetaGlob => (
2224-
"import.meta.glob".to_string(),
2225-
"The import.meta.glob() function from Vite: https://vite.dev/guide/features.html#glob-import",
2210+
"import.meta.glob".to_string(),
2211+
"The import.meta.glob() function from Vite: https://vite.dev/guide/features.html#glob-import"
22262212
),
22272213
};
22282214
if depth > 0 {

turbopack/crates/turbopack-ecmascript/src/lib.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,22 +1354,23 @@ async fn merge_modules(
13541354
// TODO looking up an Atom in a Map<RcStr, _>, would ideally work without creating a
13551355
// RcStr every time.
13561356
let sym_rc_str: RcStr = sym.as_str().into();
1357-
let (local, local_ctxt) =
1358-
if let Some((local, local_ctxt)) = eval_context_exports.get(&sym_rc_str) {
1359-
(Some(local), *local_ctxt)
1360-
} else if sym.starts_with("__TURBOPACK__imported__module__") {
1361-
// The variable corresponding to the `export * as foo from "...";` is generated
1362-
// in the module generating the reexport (and it's not listed in the
1363-
// eval_context). `EsmAssetReference::code_gen` uses a dummy span when
1364-
// generating this variable.
1365-
(None, SyntaxContext::empty())
1366-
} else {
1367-
self.error = Err(anyhow::anyhow!(
1368-
"Expected to find a local export for {sym} with ctxt {ctxt:#?} in \
1357+
let (local, local_ctxt) = if let Some((local, local_ctxt)) =
1358+
eval_context_exports.get(&sym_rc_str)
1359+
{
1360+
(Some(local), *local_ctxt)
1361+
} else if sym.starts_with("__TURBOPACK__imported__module__") {
1362+
// The variable corresponding to the `export * as foo from "...";` is generated
1363+
// in the module generating the reexport (and it's not listed in the
1364+
// eval_context). `EsmAssetReference::code_gen` uses a dummy span when
1365+
// generating this variable.
1366+
(None, SyntaxContext::empty())
1367+
} else {
1368+
self.error = Err(anyhow::anyhow!(
1369+
"Expected to find a local export for {sym} with ctxt {ctxt:#?} in \
13691370
{eval_context_exports:?}",
1370-
));
1371-
return;
1372-
};
1371+
));
1372+
return;
1373+
};
13731374

13741375
let global_ctxt = self.get_context_for(module, local_ctxt);
13751376

0 commit comments

Comments
 (0)