Skip to content

Commit b5db045

Browse files
committed
refactor: drop CJS build
1 parent db0d35c commit b5db045

File tree

7 files changed

+26
-86
lines changed

7 files changed

+26
-86
lines changed

packages/plugin-vue-jsx/build.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@ export default defineBuildConfig({
44
entries: ['src/index'],
55
clean: true,
66
declaration: true,
7-
rollup: {
8-
emitCJS: true,
9-
},
107
})

packages/plugin-vue-jsx/package.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
{
22
"name": "@vitejs/plugin-vue-jsx",
33
"version": "4.2.0",
4-
"type": "commonjs",
4+
"type": "module",
55
"license": "MIT",
66
"author": "Evan You",
77
"files": [
88
"dist"
99
],
10-
"main": "./dist/index.cjs",
11-
"module": "./dist/index.mjs",
12-
"types": "./dist/index.d.ts",
13-
"exports": {
14-
".": {
15-
"import": "./dist/index.mjs",
16-
"require": "./dist/index.cjs"
17-
}
18-
},
10+
"exports": "./dist/index.mjs",
1911
"scripts": {
2012
"dev": "unbuild --stub",
21-
"build": "unbuild && pnpm run patch-cjs",
22-
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
13+
"build": "unbuild",
2314
"prepublishOnly": "npm run build"
2415
},
2516
"engines": {

packages/plugin-vue-jsx/src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@rolldown/pluginutils'
1313
import type { Options } from './types'
1414

15-
export * from './types'
15+
export type * from './types'
1616

1717
const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper'
1818
const ssrRegisterHelperCode =
@@ -333,3 +333,12 @@ function getHash(text: string) {
333333
}
334334

335335
export default vueJsxPlugin
336+
337+
// Compat for require
338+
function vueJsxPluginCjs(this: unknown, options: Options): Plugin {
339+
return vueJsxPlugin.call(this, options)
340+
}
341+
Object.assign(vueJsxPluginCjs, {
342+
default: vueJsxPluginCjs,
343+
})
344+
export { vueJsxPluginCjs as 'module.exports' }

packages/plugin-vue/build.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default defineBuildConfig({
66
clean: true,
77
declaration: 'compatible',
88
rollup: {
9-
emitCJS: true,
109
inlineDependencies: true,
1110
},
1211
})

packages/plugin-vue/package.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
{
22
"name": "@vitejs/plugin-vue",
33
"version": "6.0.0-beta.1",
4-
"type": "commonjs",
4+
"type": "module",
55
"license": "MIT",
66
"author": "Evan You",
77
"files": [
88
"dist"
99
],
10-
"main": "./dist/index.cjs",
11-
"module": "./dist/index.mjs",
12-
"types": "./dist/index.d.ts",
13-
"exports": {
14-
".": {
15-
"import": "./dist/index.mjs",
16-
"require": "./dist/index.cjs"
17-
}
18-
},
10+
"exports": "./dist/index.mjs",
1911
"scripts": {
2012
"dev": "unbuild --stub",
21-
"build": "unbuild && pnpm run patch-cjs",
22-
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
13+
"build": "unbuild",
2314
"prepublishOnly": "npm run build"
2415
},
2516
"engines": {

packages/plugin-vue/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,13 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
517517
function ensureArray<T>(value: T | T[]): T[] {
518518
return Array.isArray(value) ? value : [value]
519519
}
520+
521+
// Compat for require
522+
function vuePluginCjs(this: unknown, options: Options): Plugin<Api> {
523+
return vuePlugin.call(this, options)
524+
}
525+
Object.assign(vuePluginCjs, {
526+
default: vuePluginCjs,
527+
parseVueRequest,
528+
})
529+
export { vuePluginCjs as 'module.exports' }

scripts/patchCJS.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)