Skip to content

Commit f9f28a3

Browse files
Bump Jiti to v2.6 (#401)
* Bump Jiti to v2.6 Nice initialization perf improvement * Patch jiti for now This would negate the perf improvement sadly. We need to chunk split this dep.
1 parent 39bf3d3 commit f9f28a3

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

build.mjs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ function patchRecast() {
3131
}
3232
}
3333

34+
/**
35+
* @returns {import('esbuild').Plugin}
36+
*/
37+
function patchJiti() {
38+
return {
39+
name: 'patch-jiti',
40+
setup(build) {
41+
// TODO: Switch to rolldown and see if we can chunk split this instead?
42+
build.onLoad({ filter: /jiti\/lib\/jiti\.mjs$/ }, async (args) => {
43+
let original = await fs.promises.readFile(args.path, 'utf8')
44+
45+
return {
46+
contents: original.replace(
47+
'createRequire(import.meta.url)("../dist/babel.cjs")',
48+
'require("../dist/babel.cjs")',
49+
),
50+
}
51+
})
52+
},
53+
}
54+
}
55+
3456
/**
3557
* @returns {import('esbuild').Plugin}
3658
*/
@@ -115,7 +137,7 @@ let context = await esbuild.context({
115137
entryPoints: [path.resolve(__dirname, './src/index.js')],
116138
outfile: path.resolve(__dirname, './dist/index.mjs'),
117139
format: 'esm',
118-
plugins: [patchRecast(), patchCjsInterop(), inlineCssImports()],
140+
plugins: [patchRecast(), patchJiti(), patchCjsInterop(), inlineCssImports()],
119141
})
120142

121143
await context.rebuild()

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"esbuild": "^0.25.9",
5252
"escalade": "^3.2.0",
5353
"import-sort-style-module": "^6.0.0",
54-
"jiti": "^2.5.1",
54+
"jiti": "^2.6.0",
5555
"jsesc": "^3.1.0",
5656
"license-checker": "^25.0.1",
5757
"line-column": "^1.0.2",

0 commit comments

Comments
 (0)