Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit c6250eb

Browse files
committed
fix: esm bundle
1 parent b52201d commit c6250eb

File tree

4 files changed

+59
-10
lines changed

4 files changed

+59
-10
lines changed

package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"*.d.ts"
5454
],
5555
"scripts": {
56-
"build": "tsup \"src/*.ts\" --format cjs,esm --clean --target esnext --dts --splitting && esno scripts/postbuild.ts",
57-
"dev": "tsup \"src/*.ts\" --watch src",
56+
"build": "tsup && esno scripts/postbuild.ts",
57+
"dev": "tsup --watch src",
5858
"lint": "eslint \"{src,test}/**/*.ts\"",
5959
"lint:fix": "nr lint -- --fix",
6060
"play": "npm -C playground run dev",
@@ -75,12 +75,12 @@
7575
"htmlparser2": "^7.1.2",
7676
"magic-string": "^0.25.7",
7777
"@rollup/pluginutils": "^4.1.1",
78+
"@antfu/utils": "^0.3.0",
7879
"unplugin": "^0.2.11"
7980
},
8081
"devDependencies": {
8182
"@antfu/eslint-config": "^0.9.0",
8283
"@antfu/ni": "^0.9.3",
83-
"@antfu/utils": "^0.3.0",
8484
"@types/jest": "^27.0.1",
8585
"@types/node": "^16.9.1",
8686
"@vue/composition-api": "^1.1.5",
@@ -99,7 +99,12 @@
9999
"typescript": "^4.4.3",
100100
"vite": "^2.5.7"
101101
},
102-
"optionalDependencies": {
102+
"peerDependencies": {
103103
"pug": "^3.0.2"
104+
},
105+
"peerDependenciesMeta": {
106+
"pug": {
107+
"optional": true
108+
}
104109
}
105110
}

pnpm-lock.yaml

+30-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/parseSFC.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { Parser as HTMLParser, ParserOptions as HTMLParserOptions } from 'htmlparser2'
2-
import { parse, ParserOptions } from '@babel/parser'
2+
import type { ParserOptions } from '@babel/parser'
3+
import * as babelParser from '@babel/parser'
34
import { camelize, capitalize, isHTMLTag, isSVGTag, isVoidTag } from '@vue/shared'
45
import { ParsedSFC, ScriptSetupTransformOptions, ScriptTagMeta } from '../types'
56
import { getIdentifierUsages } from './identifiers'
67

8+
const { parse } = babelParser
9+
710
export function parseSFC(code: string, id?: string, options?: ScriptSetupTransformOptions): ParsedSFC {
811
const components = new Set<string>()
912
const expressions = new Set<string>()

tsup.config.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Options } from 'tsup'
2+
3+
const options: Options = {
4+
format: [
5+
'cjs',
6+
'esm',
7+
],
8+
clean: true,
9+
splitting: true,
10+
dts: true,
11+
entryPoints: [
12+
'src/*.ts',
13+
],
14+
}
15+
16+
export default options

0 commit comments

Comments
 (0)