Skip to content

Commit e5120f4

Browse files
committed
support iife build
1 parent cb60147 commit e5120f4

File tree

5 files changed

+246
-29
lines changed

5 files changed

+246
-29
lines changed

package.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@
2020
"@babel/core": "^7.9.0",
2121
"@babel/preset-env": "^7.8.4",
2222
"@babel/types": "^7.8.3",
23+
"@rollup/plugin-commonjs": "^11.1.0",
24+
"@rollup/plugin-json": "^4.0.3",
2325
"@rollup/plugin-node-resolve": "^7.1.3",
26+
"@rollup/plugin-replace": "^2.3.2",
2427
"@types/estree": "^0.0.42",
2528
"@types/jest": "^24.9.1",
26-
"@types/node": "12.12.35",
2729
"@types/lodash": "^4.14.149",
30+
"@types/node": "12.12.35",
2831
"@vue/compiler-sfc": "^3.0.0-beta.2",
2932
"babel-jest": "^25.2.3",
3033
"babel-preset-jest": "^25.2.1",
3134
"flush-promises": "^1.0.2",
3235
"husky": "^4.2.3",
3336
"jest": "^25.1.0",
37+
"jsdom": "^16.2.2",
38+
"jsdom-global": "^3.0.2",
3439
"lint-staged": "^10.0.9",
3540
"prettier": "^2.0.2",
3641
"rollup": "^1.31.1",
@@ -71,7 +76,10 @@
7176
"directory": "test-dts",
7277
"compilerOptions": {
7378
"strict": false,
74-
"lib": ["esnext", "dom"]
79+
"lib": [
80+
"esnext",
81+
"dom"
82+
]
7583
}
7684
}
7785
}

rollup.config.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import ts from 'rollup-plugin-typescript2'
22
import resolve from '@rollup/plugin-node-resolve'
3+
import replace from '@rollup/plugin-replace'
4+
import commonjs from '@rollup/plugin-commonjs'
5+
import json from '@rollup/plugin-json'
36

47
import pkg from './package.json'
58

@@ -23,18 +26,24 @@ function createEntry(options) {
2326
external: [
2427
'vue',
2528
'lodash/mergeWith',
26-
'lodash/camelCase',
27-
'lodash/upperFirst',
28-
'lodash/kebabCase',
29-
'lodash/flow',
30-
'lodash/isString',
31-
'dom-event-types'
29+
'lodash/isString'
30+
],
31+
plugins: [
32+
replace({
33+
"process.env.NODE_ENV": true
34+
}),
35+
resolve(), commonjs(), json()
3236
],
33-
plugins: [resolve()],
3437
output: {
3538
banner,
36-
file: 'dist/vue-test-utils.other.js',
37-
format
39+
name: 'VueTestUtils',
40+
file: 'dist/vue-test-utils.browser.js',
41+
format,
42+
globals: {
43+
vue: 'Vue',
44+
'lodash/mergeWith': '_.mergeWith',
45+
'lodash/isString': '_.isString',
46+
}
3847
}
3948
}
4049

@@ -66,5 +75,6 @@ function createEntry(options) {
6675
export default [
6776
createEntry({ format: 'es', input: 'src/index.ts', isBrowser: false }),
6877
createEntry({ format: 'es', input: 'src/index.ts', isBrowser: true }),
78+
createEntry({ format: 'iife', input: 'src/index.ts', isBrowser: true }),
6979
createEntry({ format: 'cjs', input: 'src/index.ts', isBrowser: false }),
7080
]

src/create-dom-event.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import eventTypes from 'dom-event-types'
1+
import * as eventTypes from 'dom-event-types'
22

33
interface TriggerOptions {
44
code?: String

src/utils.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
import camelCase from 'lodash/camelCase'
2-
import upperFirst from 'lodash/upperFirst'
3-
import kebabCase from 'lodash/kebabCase'
4-
import flow from 'lodash/flow'
51
import isString from 'lodash/isString'
62
import mergeWith from 'lodash/mergeWith'
7-
import { GlobalMountOptions } from './types'
8-
9-
const pascalCase = flow(camelCase, upperFirst)
103

11-
export { kebabCase, pascalCase, isString }
4+
import { GlobalMountOptions } from './types'
125

13-
export function mergeGlobalProperties(
6+
function mergeGlobalProperties(
147
configGlobal: GlobalMountOptions = {},
158
mountGlobal: GlobalMountOptions = {}
169
): GlobalMountOptions {
@@ -32,3 +25,5 @@ export function mergeGlobalProperties(
3225
}
3326
)
3427
}
28+
29+
export { isString, mergeGlobalProperties }

0 commit comments

Comments
 (0)