Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions packages/rspack/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,16 @@ const codmodPlugin: RsbuildPlugin = {
}

api.onAfterBuild(() => {
const dist = fs.readFileSync(
require.resolve(path.resolve(import.meta.dirname, 'dist/index.js')),
'utf-8',
);
const root = parse(Lang.JavaScript, dist).root();
const edits = [...replaceBinding(root)];
for (const filename of ['index.js', 'worker.js']) {
Comment thread
hardfist marked this conversation as resolved.
const distPath = require.resolve(
path.resolve(import.meta.dirname, 'dist', filename),
);
const dist = fs.readFileSync(distPath, 'utf-8');
const root = parse(Lang.JavaScript, dist).root();
const edits = [...replaceBinding(root)];

fs.writeFileSync(
require.resolve(path.resolve(import.meta.dirname, 'dist/index.js')),
root.commitEdits(edits),
);
fs.writeFileSync(distPath, root.commitEdits(edits));
Comment thread
hardfist marked this conversation as resolved.
}
});
},
};
Expand Down
Loading