diff --git a/jest.config.js b/jest.config.js
index dff0697d7..1036103e6 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -1,12 +1,13 @@
module.exports = {
preset: 'ts-jest',
globals: {
- __USE_BUILD__: process.argv.indexOf('-use-build') >= 0
+ __USE_BUILD__: process.argv.indexOf('-use-build') >= 0,
+ __BROWSER__: true
},
testEnvironment: 'jsdom',
transform: {
- "^.+\\.vue$": "vue-jest",
- "^.+\\js$": "babel-jest"
+ '^.+\\.vue$': 'vue-jest',
+ '^.+\\js$': 'babel-jest'
},
moduleFileExtensions: ['vue', 'js', 'json', 'jsx', 'ts', 'tsx', 'node'],
setupFiles: ['./setup.js']
diff --git a/rollup.config.js b/rollup.config.js
index a752e62fe..22d503798 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -15,11 +15,7 @@ const banner = `
`
function createEntry(options) {
- const {
- format,
- input,
- isBrowser
- } = options
+ const { format, input, isBrowser } = options
const isEsmBrowser = format === 'es' && isBrowser
@@ -27,16 +23,21 @@ function createEntry(options) {
input,
external: [
'vue',
- isEsmBrowser ? '@vue/compiler-dom/dist/compiler-dom.esm-browser' : '@vue/compiler-dom',
+ isEsmBrowser
+ ? '@vue/compiler-dom/dist/compiler-dom.esm-browser'
+ : '@vue/compiler-dom'
],
plugins: [
replace({
values: {
- "process.env.NODE_ENV": "true"
+ 'process.env.NODE_ENV': 'true',
+ __BROWSER__: isEsmBrowser
},
preventAssignment: true
}),
- resolve(), commonjs(), json()
+ resolve(),
+ commonjs(),
+ json()
],
output: {
banner,
@@ -45,7 +46,7 @@ function createEntry(options) {
format,
globals: {
vue: 'Vue',
- '@vue/compiler-dom': 'VueCompilerDOM',
+ '@vue/compiler-dom': 'VueCompilerDOM'
}
}
}
@@ -82,5 +83,5 @@ export default [
createEntry({ format: 'es', input: 'src/index.ts', isBrowser: false }),
createEntry({ format: 'es', input: 'src/index.ts', isBrowser: true }),
createEntry({ format: 'iife', input: 'src/index.ts', isBrowser: true }),
- createEntry({ format: 'cjs', input: 'src/index.ts', isBrowser: false }),
+ createEntry({ format: 'cjs', input: 'src/index.ts', isBrowser: false })
]
diff --git a/src/utils/compileSlots.ts b/src/utils/compileSlots.ts
index 35fc6d7fc..c965ae077 100644
--- a/src/utils/compileSlots.ts
+++ b/src/utils/compileSlots.ts
@@ -15,10 +15,13 @@ export function processSlot(source = '', Vue = vue) {
`${template}`,
{
mode: 'function',
- prefixIdentifiers: true
+ prefixIdentifiers: __BROWSER__
}
)
- const createRenderFunction = new Function('Vue', `'use strict';\n${code}`)
+ const createRenderFunction = new Function(
+ 'Vue',
+ __BROWSER__ ? `'use strict';\n${code}` : code
+ )
return {
inheritAttrs: false,
diff --git a/test-dts/index.d.ts b/test-dts/index.d.ts
index ee0e8dec5..98d474d98 100644
--- a/test-dts/index.d.ts
+++ b/test-dts/index.d.ts
@@ -4,14 +4,16 @@
// it's intended. We cannot use directives like @ts-ignore or @ts-nocheck since
// that would suppress the errors that should be caught.
+import '../types/global'
+
export function describe(_name: string, _fn: () => void): void
export function expectType(value: T): void
export function expectError(value: T): void
export function expectAssignable(value: T2): void
-export type IsUnion = (T extends any
- ? (U extends T ? false : true)
- : never) extends false
+export type IsUnion = (
+ T extends any ? (U extends T ? false : true) : never
+) extends false
? false
: true
diff --git a/types/global.d.ts b/types/global.d.ts
new file mode 100644
index 000000000..08c128f6c
--- /dev/null
+++ b/types/global.d.ts
@@ -0,0 +1 @@
+declare var __BROWSER__: boolean