Skip to content

Commit

Permalink
chore: switch to oxc for dts & typescript transform
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Feb 16, 2025
1 parent 7bfa70c commit 2422903
Show file tree
Hide file tree
Showing 3 changed files with 810 additions and 219 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"esbuild": "^0.25.0",
"eslint": "^9.20.0",
"magic-string": "^0.30.17",
"oxc-transform": "^0.51.0",
"pathe": "^2.0.2",
"rimraf": "^6.0.1",
"rollup": "^4.34.6",
Expand All @@ -62,6 +63,8 @@
"tinyglobby": "^0.2.10",
"tsx": "^4.19.2",
"typescript": "^5.7.3",
"unplugin-isolated-decl": "^0.11.0",
"unplugin-oxc": "^0.2.4",
"vite": "^6.0.11",
"vitest": "workspace:*",
"zx": "^8.3.2"
Expand Down
44 changes: 30 additions & 14 deletions packages/browser/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { rm } from 'node:fs/promises'
import { createRequire } from 'node:module'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import { defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
import isolatedDecl from 'unplugin-isolated-decl/rollup'
import oxc from 'unplugin-oxc/rollup'

const require = createRequire(import.meta.url)
const pkg = require('./package.json')
Expand All @@ -24,8 +26,8 @@ const plugins = [
}),
json(),
commonjs(),
esbuild({
target: 'node18',
oxc({
transform: { target: 'node18' },
}),
]

Expand Down Expand Up @@ -58,6 +60,7 @@ export default () =>
}
},
},
isolatedDecl({ transformer: 'oxc', extraOutdir: '.node-types' }),
...plugins,
],
},
Expand All @@ -74,7 +77,10 @@ export default () =>
format: 'esm',
},
external,
plugins,
plugins: [
isolatedDecl({ transformer: 'oxc', extraOutdir: '.client-types' }),
plugins,
],
},
{
input: './src/client/tester/context.ts',
Expand All @@ -83,9 +89,7 @@ export default () =>
format: 'esm',
},
plugins: [
esbuild({
target: 'node18',
}),
oxc({ transform: { target: 'node18' } }),
],
},
{
Expand All @@ -98,8 +102,8 @@ export default () =>
resolve({
preferBuiltins: true,
}),
esbuild({
target: 'node18',
oxc({
transform: { target: 'node18' },
}),
],
},
Expand All @@ -110,15 +114,15 @@ export default () =>
format: 'iife',
},
plugins: [
esbuild({
target: 'node18',
minifyWhitespace: true,
oxc({
transform: { target: 'node18' },
minify: true,
}),
resolve(),
],
},
{
input: input.index,
input: './dist/.node-types/index.d.ts',
output: {
file: 'dist/index.d.ts',
format: 'esm',
Expand All @@ -128,11 +132,17 @@ export default () =>
dts({
respectExternal: true,
}),
{
name: 'cleanup',
buildEnd() {
return rm('./dist/.node-types', { recursive: true, force: true })
},
},
],
},
{
input: {
'locators/index': './src/client/tester/locators/index.ts',
'locators/index': './dist/.client-types/locators/index.d.ts',
},
output: {
dir: 'dist',
Expand All @@ -143,6 +153,12 @@ export default () =>
dts({
respectExternal: true,
}),
{
name: 'cleanup',
buildEnd() {
return rm('./dist/.client-types', { recursive: true, force: true })
},
},
],
},
// {
Expand Down
Loading

0 comments on commit 2422903

Please sign in to comment.