Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony committed Aug 1, 2023
1 parent 454b883 commit 9b69862
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 25 deletions.
3 changes: 1 addition & 2 deletions crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ function loadChunkAsync(source: SourceInfo, chunkPath: string): Promise<void> {
}

function loadWebAssembly(chunkPath: ChunkPath, imports: WebAssembly.Imports) {
const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));
delete require.cache[resolved];
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);

return loadWebAssemblyFromPath(resolved, imports)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module {

// NOTE(alexkirsz) This can fail when the module encounters a runtime error.
try {
const sourceInfo: SourceInfo = { type: SourceType.Parent, parentId: id };

runModuleExecutionHooks(module, (refresh) => {
moduleFactory.call(
module.exports,
Expand All @@ -331,8 +333,8 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module {
n: exportNamespace.bind(null, module),
m: module,
c: moduleCache,
l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),
w: loadWebAssembly.bind(null, { type: SourceType.Parent, parentId: id }),
l: loadChunk.bind(null, sourceInfo),
w: loadWebAssembly.bind(null, sourceInfo),
g: globalThis,
k: refresh,
__dirname: module.id.replace(/(^|\/)\/+$/, ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ function resolveChunkPath(chunkPath: ChunkPath, source: SourceInfo) {
break;
}

const path = require("path");
const resolved = require.resolve(
const path = require("node:path/posix");
return require.resolve(
"./" + path.relative(path.dirname(fromChunkPath), chunkPath)
);

return resolved;
}

function loadWebAssembly(
Expand Down

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

Large diffs are not rendered by default.

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

Loading

0 comments on commit 9b69862

Please sign in to comment.