Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deps): bump jiti to v2 #4191

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"@rspack/core": "~1.1.6",
"@rspack/lite-tapable": "~1.0.1",
"@swc/helpers": "^0.5.15",
"core-js": "~3.39.0"
"core-js": "~3.39.0",
"jiti": "2.4.1"
},
"devDependencies": {
"@rslib/core": "0.1.3",
Expand All @@ -75,7 +76,6 @@
"dotenv-expand": "11.0.7",
"html-rspack-plugin": "6.0.2",
"http-proxy-middleware": "^2.0.6",
"jiti": "^1.21.6",
"launch-editor-middleware": "^2.9.1",
"mrmime": "^2.0.0",
"on-finished": "2.4.1",
Expand Down
14 changes: 3 additions & 11 deletions packages/core/prebundle.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ export default {
);
},
},
{
name: 'jiti',
// jiti has been minified, we do not need to prettier it
prettier: false,
ignoreDts: true,
},
{
name: 'launch-editor-middleware',
ignoreDts: true,
Expand Down Expand Up @@ -172,7 +166,7 @@ export default {
{
name: 'postcss-loader',
externals: {
jiti: '../jiti',
jiti: 'jiti',
semver: './semver',
postcss: '../postcss',
},
Expand All @@ -190,16 +184,14 @@ export default {
name: 'postcss-load-config',
externals: {
yaml: 'yaml',
'../jiti': '../jiti',
jiti: 'jiti',
},
ignoreDts: true,
// this is a trick to avoid ncc compiling the dynamic import syntax
// https://github.com/vercel/ncc/issues/935
beforeBundle(task) {
replaceFileContent(join(task.depPath, 'src/req.js'), (content) =>
content
.replaceAll('await import', 'await __import')
.replaceAll(`import('jiti')`, `import('../jiti/index.js')`),
content.replaceAll('await import', 'await __import'),
);
},
afterBundle(task) {
Expand Down
11 changes: 6 additions & 5 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,16 @@ export async function loadConfig({

try {
if (configExport! === undefined) {
const { default: jiti } = await import('../compiled/jiti/index.js');
const loadConfig = jiti(__filename, {
esmResolve: true,
const { createJiti } = await import('jiti');
const jiti = createJiti(__filename, {
// disable require cache to support restart CLI and read the new config
requireCache: false,
moduleCache: false,
interopDefault: true,
});

configExport = loadConfig(configFilePath) as RsbuildConfigExport;
configExport = await jiti.import<RsbuildConfigExport>(configFilePath, {
default: true,
});
}
} catch (err) {
logger.error(`Failed to load file with jiti: ${color.dim(configFilePath)}`);
Expand Down
24 changes: 15 additions & 9 deletions pnpm-lock.yaml

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

Loading