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

Commit c978c46

Browse files
committed
fix: remove mjs build
1 parent 36733c6 commit c978c46

7 files changed

+17
-30
lines changed

package.json

+6-13
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,29 @@
1616
"author": "Anthony Fu <[email protected]>",
1717
"exports": {
1818
".": {
19-
"require": "./dist/index.js",
20-
"import": "./dist/index.mjs"
19+
"require": "./dist/index.js"
2120
},
2221
"./*": "./*",
2322
"./jest": {
2423
"require": "./jest.js"
2524
},
2625
"./nuxt": {
27-
"require": "./dist/nuxt.js",
28-
"import": "./dist/nuxt.mjs"
26+
"require": "./dist/nuxt.js"
2927
},
3028
"./rollup": {
31-
"require": "./dist/rollup.js",
32-
"import": "./dist/rollup.mjs"
29+
"require": "./dist/rollup.js"
3330
},
3431
"./types": {
35-
"require": "./dist/types.js",
36-
"import": "./dist/types.mjs"
32+
"require": "./dist/types.js"
3733
},
3834
"./vite": {
39-
"require": "./dist/vite.js",
40-
"import": "./dist/vite.mjs"
35+
"require": "./dist/vite.js"
4136
},
4237
"./webpack": {
43-
"require": "./dist/webpack.js",
44-
"import": "./dist/webpack.mjs"
38+
"require": "./dist/webpack.js"
4539
}
4640
},
4741
"main": "dist/index.js",
48-
"module": "dist/index.mjs",
4942
"types": "index.d.ts",
5043
"files": [
5144
"dist",

src/core/babel.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { types as t } from '@babel/core'
2+
import { parseExpression, parse } from '@babel/parser'
3+
4+
export { t, parseExpression, parse }

src/core/macros.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import type {
1111
CallExpression,
1212
TSInterfaceBody,
1313
} from '@babel/types'
14-
import * as babelCore from '@babel/core'
15-
import * as babelParser from '@babel/parser'
16-
17-
const { types: t } = babelCore
18-
const { parseExpression } = babelParser
14+
import { parseExpression, t } from './babel'
1915

2016
// Special compiler macros
2117
const DEFINE_PROPS = 'defineProps'

src/core/parseSFC.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { Parser as HTMLParser, ParserOptions as HTMLParserOptions } from 'htmlparser2'
22
import type { ParserOptions } from '@babel/parser'
3-
import * as babelParser from '@babel/parser'
43
import { camelize, capitalize, isHTMLTag, isSVGTag, isVoidTag } from '@vue/shared'
54
import { ParsedSFC, ScriptSetupTransformOptions, ScriptTagMeta } from '../types'
65
import { getIdentifierUsages } from './identifiers'
7-
8-
const { parse } = babelParser
6+
import { parse } from './babel'
97

108
export function parseSFC(code: string, id?: string, options?: ScriptSetupTransformOptions): ParsedSFC {
119
const components = new Set<string>()

src/core/transformScriptSetup.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import * as babelCore from '@babel/core'
21
import { camelize, capitalize } from '@vue/shared'
32
import type { Node, ObjectExpression, Statement } from '@babel/types'
43
import generate from '@babel/generator'
54
import { partition } from '@antfu/utils'
65
import { ParsedSFC, ScriptSetupTransformOptions } from '../types'
76
import { applyMacros } from './macros'
87
import { getIdentifierDeclarations } from './identifiers'
9-
10-
const { types: t } = babelCore
8+
import { t } from './babel'
119

1210
function isAsyncImport(node: any) {
1311
if (node.type === 'VariableDeclaration') {

src/core/transformSfcRefSugar.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { shouldTransform, transformAST } from '@vue/ref-transform'
22
import MagicString from 'magic-string'
3-
import * as babelParser from '@babel/parser'
4-
import * as babelCore from '@babel/core'
53
import type { ParsedSFC, ResolvedOptions } from '../types'
6-
7-
const { types: t } = babelCore
8-
const { parse } = babelParser
4+
import { t, parse } from './babel'
95

106
export function transformSfcRefSugar(sfc: ParsedSFC, options: ResolvedOptions) {
117
const importedHelpers = new Set<string>()

tsup.config.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { Options } from 'tsup'
33
const options: Options = {
44
format: [
55
'cjs',
6-
'esm',
6+
// loading Babel in ESM is tricky, since Babel itself it CJS only
7+
// we decided to drop ESM support until Babel supports native ESM
8+
// 'esm',
79
],
810
clean: true,
911
splitting: true,

0 commit comments

Comments
 (0)