Skip to content

Commit cd96e33

Browse files
committed
fix(rspack): use createRequire
1 parent 0e52fd2 commit cd96e33

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

rspack.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {sentryWebpackPlugin} from '@sentry/webpack-plugin/webpack5';
1414
import CompressionPlugin from 'compression-webpack-plugin';
1515
import HtmlWebpackPlugin from 'html-webpack-plugin';
1616
import fs from 'node:fs';
17+
import {createRequire} from 'node:module';
1718
import path from 'node:path';
1819
import {TsCheckerRspackPlugin} from 'ts-checker-rspack-plugin';
1920

@@ -82,6 +83,8 @@ const DEPLOY_PREVIEW_CONFIG = IS_DEPLOY_PREVIEW && {
8283
githubRepo: env.NOW_GITHUB_COMMIT_REPO,
8384
};
8485

86+
const require = createRequire(import.meta.url);
87+
8588
// When deploy previews are enabled always enable experimental SPA mode --
8689
// deploy previews are served standalone. Otherwise fallback to the environment
8790
// configuration.
@@ -469,7 +472,7 @@ const appConfig: Configuration = {
469472
// `yarn why` says this is only needed in dev deps
470473
string_decoder: false,
471474
// For framer motion v6, might be able to remove on v11
472-
'process/browser': import.meta.resolve('process/browser'),
475+
'process/browser': require.resolve('process/browser'),
473476
},
474477

475478
// Prefers local modules over node_modules
@@ -805,7 +808,7 @@ if (IS_PRODUCTION) {
805808
}
806809

807810
if (CODECOV_TOKEN && ENABLE_CODECOV_BA) {
808-
const {codecovWebpackPlugin} = await import('@codecov/webpack-plugin');
811+
const {codecovWebpackPlugin} = require('@codecov/webpack-plugin');
809812
// defaulting to an empty string which in turn will fallback to env var or
810813
// determine merge commit sha from git
811814
const GH_COMMIT_SHA = env.GH_COMMIT_SHA ?? '';

0 commit comments

Comments
 (0)