v6.0.0-alpha.36
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
module.exports = require('./dist/vue-tippy.prod.cjs')
|
||||||
|
} else {
|
||||||
|
module.exports = require('./dist/vue-tippy.cjs')
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
module.exports = require('./dist/vue-tippy.cjs.prod.js')
|
module.exports = require('./dist/vue-tippy.prod.cjs')
|
||||||
} else {
|
} else {
|
||||||
module.exports = require('./dist/vue-tippy.cjs.js')
|
module.exports = require('./dist/vue-tippy.cjs')
|
||||||
}
|
}
|
||||||
+16
-8
@@ -1,21 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-tippy",
|
"name": "vue-tippy",
|
||||||
"version": "6.0.0-alpha.35",
|
"version": "6.0.0-alpha.36",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/vue-tippy.esm-bundler.js",
|
"module": "dist/vue-tippy.mjs",
|
||||||
"unpkg": "dist/vue-tippy.iife.js",
|
"unpkg": "dist/vue-tippy.iife.js",
|
||||||
"jsdelivr": "dist/vue-tippy.iife.js",
|
"jsdelivr": "dist/vue-tippy.iife.js",
|
||||||
"types": "dist/vue-tippy.d.ts",
|
"types": "dist/vue-tippy.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"browser": "./dist/vue-tippy.esm-browser.js",
|
||||||
"node": "./index.mjs",
|
"node": {
|
||||||
"default": "./dist/vue-tippy.esm-bundler.js"
|
"import": {
|
||||||
|
"production": "./dist/vue-tippy.prod.cjs",
|
||||||
|
"development": "./dist/vue-tippy.mjs",
|
||||||
|
"default": "./dist/vue-tippy.mjs"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"production": "./dist/vue-tippy.prod.cjs",
|
||||||
|
"development": "./dist/vue-tippy.cjs",
|
||||||
|
"default": "./index.js"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"require": "./index.js"
|
"import": "./dist/vue-tippy.mjs"
|
||||||
},
|
},
|
||||||
"./package.json": "./package.json",
|
"./package.json": "./package.json",
|
||||||
"./index.mjs": "./index.mjs",
|
|
||||||
"./dist/*": "./dist/*"
|
"./dist/*": "./dist/*"
|
||||||
},
|
},
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
@@ -26,7 +34,7 @@
|
|||||||
"dist/*.cjs",
|
"dist/*.cjs",
|
||||||
"dist/vue-tippy.d.ts",
|
"dist/vue-tippy.d.ts",
|
||||||
"index.js",
|
"index.js",
|
||||||
"index.mjs",
|
"index.cjs",
|
||||||
"vetur/*.json",
|
"vetur/*.json",
|
||||||
"LICENSE",
|
"LICENSE",
|
||||||
"README.md"
|
"README.md"
|
||||||
|
|||||||
+71
-43
@@ -3,14 +3,27 @@ import ts from 'rollup-plugin-typescript2'
|
|||||||
import replace from '@rollup/plugin-replace'
|
import replace from '@rollup/plugin-replace'
|
||||||
import resolve from '@rollup/plugin-node-resolve'
|
import resolve from '@rollup/plugin-node-resolve'
|
||||||
import commonjs from '@rollup/plugin-commonjs'
|
import commonjs from '@rollup/plugin-commonjs'
|
||||||
import postcss from 'rollup-plugin-postcss'
|
import pascalcase from 'pascalcase'
|
||||||
|
|
||||||
const pkg = require('./package.json')
|
const pkg = require('./package.json')
|
||||||
const name = pkg.name
|
const name = pkg.name
|
||||||
|
|
||||||
|
function getAuthors(pkg) {
|
||||||
|
const { contributors, author } = pkg
|
||||||
|
|
||||||
|
const authors = new Set()
|
||||||
|
if (contributors && contributors)
|
||||||
|
contributors.forEach((contributor) => {
|
||||||
|
authors.add(contributor.name)
|
||||||
|
})
|
||||||
|
if (author) authors.add(author.name)
|
||||||
|
|
||||||
|
return Array.from(authors).join(', ')
|
||||||
|
}
|
||||||
|
|
||||||
const banner = `/*!
|
const banner = `/*!
|
||||||
* ${pkg.name} v${pkg.version}
|
* ${pkg.name} v${pkg.version}
|
||||||
* (c) ${new Date().getFullYear()} Georges KABBOUCHI
|
* (c) ${new Date().getFullYear()} ${getAuthors(pkg)}
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/`
|
*/`
|
||||||
|
|
||||||
@@ -25,66 +38,71 @@ const outputConfigs = {
|
|||||||
format: `es`,
|
format: `es`,
|
||||||
},
|
},
|
||||||
cjs: {
|
cjs: {
|
||||||
file: pkg.module.replace('esm-bundler', 'cjs'),
|
file: pkg.module.replace('mjs', 'cjs'),
|
||||||
format: `cjs`,
|
format: `cjs`,
|
||||||
},
|
},
|
||||||
global: {
|
global: {
|
||||||
file: pkg.unpkg,
|
file: pkg.unpkg,
|
||||||
format: `iife`,
|
format: `iife`,
|
||||||
},
|
},
|
||||||
|
browser: {
|
||||||
|
file: 'dist/vue-tippy.esm-browser.js',
|
||||||
|
format: `es`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const allFormats = Object.keys(outputConfigs)
|
const packageBuilds = Object.keys(outputConfigs)
|
||||||
// in vue-router there are not that many
|
const packageConfigs = packageBuilds.map((format) =>
|
||||||
const packageFormats = allFormats
|
|
||||||
const packageConfigs = packageFormats.map(format =>
|
|
||||||
createConfig(format, outputConfigs[format])
|
createConfig(format, outputConfigs[format])
|
||||||
)
|
)
|
||||||
|
|
||||||
// only add the production ready if we are bundling the options
|
// only add the production ready if we are bundling the options
|
||||||
packageFormats.forEach(format => {
|
packageBuilds.forEach((buildName) => {
|
||||||
if (format === 'cjs') {
|
if (buildName === 'cjs') {
|
||||||
packageConfigs.push(createProductionConfig(format))
|
packageConfigs.push(createProductionConfig(buildName))
|
||||||
} else if (format === 'global') {
|
} else if (buildName === 'global') {
|
||||||
packageConfigs.push(createMinifiedConfig(format))
|
packageConfigs.push(createMinifiedConfig(buildName))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export default packageConfigs
|
export default packageConfigs
|
||||||
|
|
||||||
function createConfig(format, output, plugins = []) {
|
function createConfig(buildName, output, plugins = []) {
|
||||||
if (!output) {
|
if (!output) {
|
||||||
console.log(require('chalk').yellow(`invalid format: "${format}"`))
|
console.log(require('chalk').yellow(`invalid format: "${buildName}"`))
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
output.sourcemap = !!process.env.SOURCE_MAP
|
output.sourcemap = !!process.env.SOURCE_MAP
|
||||||
output.banner = banner
|
output.banner = banner
|
||||||
output.externalLiveBindings = false
|
output.externalLiveBindings = false
|
||||||
output.globals = { 'vue': 'Vue' }
|
output.globals = {
|
||||||
output.exports = 'named'
|
'vue-demi': 'VueDemi',
|
||||||
|
vue: 'Vue',
|
||||||
|
'@vue/composition-api': 'vueCompositionApi',
|
||||||
|
}
|
||||||
|
|
||||||
const isProductionBuild = output.file.endsWith('.prod.js')
|
const isProductionBuild = /\.prod\.[cmj]s$/.test(output.file)
|
||||||
const isGlobalBuild = format === 'global'
|
const isGlobalBuild = buildName === 'global'
|
||||||
const isRawESMBuild = format === 'esm'
|
const isRawESMBuild = buildName === 'browser'
|
||||||
const isNodeBuild = format === 'cjs'
|
const isNodeBuild = buildName === 'cjs'
|
||||||
const isBundlerESMBuild = format === 'esm' || format === 'mjs'
|
const isBundlerESMBuild = buildName === 'browser' || buildName === 'mjs'
|
||||||
|
|
||||||
if (isGlobalBuild) output.name = 'VueTippy'
|
if (isGlobalBuild) output.name = pascalcase(pkg.name)
|
||||||
|
|
||||||
const shouldEmitDeclarations = !hasTSChecked
|
const shouldEmitDeclarations = !hasTSChecked
|
||||||
|
|
||||||
const tsPlugin = ts({
|
const tsPlugin = ts({
|
||||||
check: !hasTSChecked,
|
check: !hasTSChecked,
|
||||||
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
|
tsconfig: path.resolve(__dirname, './tsconfig.json'),
|
||||||
cacheRoot: path.resolve(__dirname, 'node_modules/.rts2_cache'),
|
cacheRoot: path.resolve(__dirname, './node_modules/.rts2_cache'),
|
||||||
tsconfigOverride: {
|
tsconfigOverride: {
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
sourceMap: output.sourcemap,
|
sourceMap: output.sourcemap,
|
||||||
declaration: shouldEmitDeclarations,
|
declaration: shouldEmitDeclarations,
|
||||||
declarationMap: shouldEmitDeclarations,
|
declarationMap: shouldEmitDeclarations,
|
||||||
},
|
},
|
||||||
exclude: [],
|
exclude: ['packages/*/__tests__', 'packages/*/test-dts'],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
// we only need to check TS and generate declarations once for each build.
|
// we only need to check TS and generate declarations once for each build.
|
||||||
@@ -92,7 +110,10 @@ function createConfig(format, output, plugins = []) {
|
|||||||
// during a single build.
|
// during a single build.
|
||||||
hasTSChecked = true
|
hasTSChecked = true
|
||||||
|
|
||||||
const external = ['vue']
|
const external = ['vue-demi', 'vue', '@vue/composition-api']
|
||||||
|
if (!isGlobalBuild) {
|
||||||
|
external.push('@vue/devtools-api')
|
||||||
|
}
|
||||||
|
|
||||||
const nodePlugins = [resolve(), commonjs()]
|
const nodePlugins = [resolve(), commonjs()]
|
||||||
|
|
||||||
@@ -113,7 +134,6 @@ function createConfig(format, output, plugins = []) {
|
|||||||
),
|
),
|
||||||
...nodePlugins,
|
...nodePlugins,
|
||||||
...plugins,
|
...plugins,
|
||||||
postcss(),
|
|
||||||
],
|
],
|
||||||
output,
|
output,
|
||||||
// onwarn: (msg, warn) => {
|
// onwarn: (msg, warn) => {
|
||||||
@@ -134,35 +154,43 @@ function createReplacePlugin(
|
|||||||
const replacements = {
|
const replacements = {
|
||||||
__COMMIT__: `"${process.env.COMMIT}"`,
|
__COMMIT__: `"${process.env.COMMIT}"`,
|
||||||
__VERSION__: `"${pkg.version}"`,
|
__VERSION__: `"${pkg.version}"`,
|
||||||
__DEV__: isBundlerESMBuild
|
__DEV__:
|
||||||
? // preserve to be handled by bundlers
|
isBundlerESMBuild || (isNodeBuild && !isProduction)
|
||||||
`(process.env.NODE_ENV !== 'production')`
|
? // preserve to be handled by bundlers
|
||||||
: // hard coded dev/prod builds
|
`(process.env.NODE_ENV !== 'production')`
|
||||||
!isProduction,
|
: // hard coded dev/prod builds
|
||||||
|
JSON.stringify(!isProduction),
|
||||||
// this is only used during tests
|
// this is only used during tests
|
||||||
__TEST__: isBundlerESMBuild ? `(process.env.NODE_ENV === 'test')` : false,
|
__TEST__:
|
||||||
|
isBundlerESMBuild || isNodeBuild
|
||||||
|
? `(process.env.NODE_ENV === 'test')`
|
||||||
|
: 'false',
|
||||||
// If the build is expected to run directly in the browser (global / esm builds)
|
// If the build is expected to run directly in the browser (global / esm builds)
|
||||||
__BROWSER__: isBrowserBuild,
|
__BROWSER__: JSON.stringify(isBrowserBuild),
|
||||||
// is targeting bundlers?
|
// is targeting bundlers?
|
||||||
__BUNDLER__: isBundlerESMBuild,
|
__BUNDLER__: JSON.stringify(isBundlerESMBuild),
|
||||||
__GLOBAL__: isGlobalBuild,
|
__GLOBAL__: JSON.stringify(isGlobalBuild),
|
||||||
// is targeting Node (SSR)?
|
// is targeting Node (SSR)?
|
||||||
__NODE_JS__: isNodeBuild,
|
__NODE_JS__: JSON.stringify(isNodeBuild),
|
||||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
||||||
}
|
}
|
||||||
// allow inline overrides like
|
// allow inline overrides like
|
||||||
//__RUNTIME_COMPILE__=true yarn build
|
//__RUNTIME_COMPILE__=true yarn build
|
||||||
Object.keys(replacements).forEach(key => {
|
Object.keys(replacements).forEach((key) => {
|
||||||
if (key in process.env) {
|
if (key in process.env) {
|
||||||
replacements[key] = process.env[key]
|
replacements[key] = process.env[key]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return replace(replacements)
|
return replace({
|
||||||
|
preventAssignment: true,
|
||||||
|
values: replacements,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function createProductionConfig(format) {
|
function createProductionConfig(format) {
|
||||||
|
const extension = format === 'cjs' ? 'cjs' : 'js'
|
||||||
|
const descriptor = format === 'cjs' ? '' : `.${format}`
|
||||||
return createConfig(format, {
|
return createConfig(format, {
|
||||||
file: `dist/${name}.${format}.prod.js`,
|
file: `dist/${name}${descriptor}.prod.${extension}`,
|
||||||
format: outputConfigs[format].format,
|
format: outputConfigs[format].format,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -172,7 +200,7 @@ function createMinifiedConfig(format) {
|
|||||||
return createConfig(
|
return createConfig(
|
||||||
format,
|
format,
|
||||||
{
|
{
|
||||||
file: `dist/${name}.${format}.prod.js`,
|
file: `dist/${name}.${format === 'global' ? 'iife' : format}.prod.js`,
|
||||||
format: outputConfigs[format].format,
|
format: outputConfigs[format].format,
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
@@ -185,4 +213,4 @@ function createMinifiedConfig(format) {
|
|||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user