Skip to content

Commit

Permalink
Revert "Turbopack: Register react refresh exports in module factory (#…
Browse files Browse the repository at this point in the history
…8191)" (#8214)

This caused issues with the Next.js test suite. See
vercel/next.js#66128

This reverts commit b0a9c9b.
  • Loading branch information
wbinnssmith committed May 26, 2024
1 parent 9004d1b commit 63c39e6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ declare var $RefreshInterceptModuleExecution$:
type RefreshContext = {
register: RefreshRuntimeGlobals["$RefreshReg$"];
signature: RefreshRuntimeGlobals["$RefreshSig$"];
registerExports: typeof registerExportsAndSetupBoundaryForReactRefresh;
};

type RefreshHelpers = RefreshRuntimeGlobals["$RefreshHelpers$"];
Expand Down Expand Up @@ -404,8 +403,16 @@ function runModuleExecutionHooks(
executeModule({
register: globalThis.$RefreshReg$,
signature: globalThis.$RefreshSig$,
registerExports: registerExportsAndSetupBoundaryForReactRefresh,
});

if ("$RefreshHelpers$" in globalThis) {
// This pattern can also be used to register the exports of
// a module with the React Refresh runtime.
registerExportsAndSetupBoundaryForReactRefresh(
module,
globalThis.$RefreshHelpers$
);
}
} catch (e) {
throw e;
} finally {
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/chunk/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl EcmascriptChunkItemContent {
if this.options.refresh {
args.push("k: __turbopack_refresh__");
}
if this.options.module || this.options.refresh {
if this.options.module {
args.push("m: module");
}
if this.options.exports {
Expand Down
21 changes: 3 additions & 18 deletions crates/turbopack-ecmascript/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ use swc_core::{
common::{chain, collections::AHashMap, comments::Comments, util::take::Take, Mark, SourceMap},
ecma::{
ast::{Module, ModuleItem, Program, Script},
preset_env::{self, Targets},
preset_env::{
Targets, {self},
},
transforms::{
base::{feature::FeatureFlag, helpers::inject_helpers, Assumptions},
optimization::inline_globals2,
react::react,
},
visit::{FoldWith, VisitMutWith},
},
quote,
};
use turbo_tasks::{ValueDefault, Vc};
use turbo_tasks_fs::FileSystemPath;
Expand Down Expand Up @@ -197,22 +198,6 @@ impl EcmascriptInputTransform {
top_level_mark,
unresolved_mark,
));

if *refresh {
let stmt = quote!(
"\n__turbopack_refresh__.registerExports(module, \
globalThis.$RefreshHelpers$); }\n" as Stmt
);

match program {
Program::Module(module) => {
module.body.push(ModuleItem::Stmt(stmt));
}
Program::Script(script) => {
script.body.push(stmt);
}
}
}
}
EcmascriptInputTransform::CommonJs => {
// Explicit type annotation to ensure that we don't duplicate transforms in the
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 63c39e6

Please sign in to comment.