File tree 4 files changed +39
-4
lines changed
4 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 42
42
"@typescript-eslint/parser" : " ^5.8.1" ,
43
43
"conventional-changelog-cli" : " ^2.2.2" ,
44
44
"cross-env" : " ^7.0.3" ,
45
- "esbuild" : " 0.14.3 " ,
45
+ "esbuild" : " ^ 0.14.14 " ,
46
46
"eslint" : " ^8.5.0" ,
47
47
"eslint-define-config" : " ^1.2.1" ,
48
48
"eslint-plugin-node" : " ^11.1.0" ,
Original file line number Diff line number Diff line change 13
13
"dev-types" : " tsc -p . -w --incremental --emitDeclarationOnly" ,
14
14
"dev-watch" : " esbuild src/index.ts --watch --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js" ,
15
15
"build" : " rimraf dist && run-s build-bundle build-types" ,
16
- "build-bundle" : " esbuild src/index.ts --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js" ,
16
+ "build-bundle" : " esbuild src/index.ts --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js & npm run patch-dist" ,
17
+ "patch-dist" : " ts-node ../../scripts/patchEsbuildDist.ts dist/index.js vuePlugin" ,
17
18
"build-types" : " tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp" ,
18
19
"changelog" : " conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-vue" ,
19
20
"release" : " ts-node ../../scripts/release.ts"
Original file line number Diff line number Diff line change @@ -244,5 +244,8 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
244
244
}
245
245
246
246
// overwrite for cjs require('...')() usage
247
- module . exports = vuePlugin
248
- vuePlugin [ 'default' ] = vuePlugin
247
+ // The following lines are inserted by scripts/patchEsbuildDist.ts,
248
+ // this doesn't bundle correctly after esbuild 0.14.4
249
+ //
250
+ // module.exports = vuePlugin
251
+ // vuePlugin['default'] = vuePlugin
Original file line number Diff line number Diff line change
1
+ // esbuild 0.14.4 https://github.com/evanw/esbuild/blob/master/CHANGELOG.md#0144 introduced a
2
+ // change that breaks the "overwrite for cjs require('...')() usage" hack used in plugin-vue
3
+ // and plugin-react. For the moment, we can remove the extra exports code added in 0.14.4 to
4
+ // continue using it.
5
+
6
+ import { bold , red } from 'picocolors'
7
+ import { readFileSync , writeFileSync } from 'fs'
8
+
9
+ const indexPath = process . argv [ 2 ]
10
+ const varName = process . argv [ 3 ]
11
+
12
+ let code = readFileSync ( indexPath , 'utf-8' )
13
+
14
+ const moduleExportsLine = `module.exports = __toCommonJS(src_exports);`
15
+
16
+ if ( code . includes ( moduleExportsLine ) ) {
17
+ // overwrite for cjs require('...')() usage
18
+ code = code . replace (
19
+ moduleExportsLine ,
20
+ `module.exports = ${ varName } ;
21
+ ${ varName } ['default'] = ${ varName } ;`
22
+ )
23
+
24
+ writeFileSync ( indexPath , code )
25
+
26
+ console . log (
27
+ bold ( `${ indexPath } patched with overwrite for cjs require('...')()` )
28
+ )
29
+ } else {
30
+ console . error ( red ( `${ indexPath } post-esbuild bundling patch failed` ) )
31
+ }
You can’t perform that action at this time.
0 commit comments