Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -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']
Expand Down
21 changes: 11 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,29 @@ const banner = `
`

function createEntry(options) {
const {
format,
input,
isBrowser
} = options
const { format, input, isBrowser } = options

const isEsmBrowser = format === 'es' && isBrowser

const config = {
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,
Expand All @@ -45,7 +46,7 @@ function createEntry(options) {
format,
globals: {
vue: 'Vue',
'@vue/compiler-dom': 'VueCompilerDOM',
'@vue/compiler-dom': 'VueCompilerDOM'
}
}
}
Expand Down Expand Up @@ -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 })
]
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var __BROWSER__: boolean
7 changes: 5 additions & 2 deletions src/utils/compileSlots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export function processSlot(source = '', Vue = vue) {
`<SlotWrapper v-bind="$attrs">${template}</SlotWrapper>`,
{
mode: 'function',
prefixIdentifiers: true
prefixIdentifiers: __BROWSER__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may need to update tsconfig (or somewhere else?) to make this compile.

}
)
const createRenderFunction = new Function('Vue', `'use strict';\n${code}`)
const createRenderFunction = new Function(
'Vue',
__BROWSER__ ? `'use strict';\n${code}` : code
)

return {
inheritAttrs: false,
Expand Down