1
Fork 0

typescript(option): fix: fixed lib not beeing tree-shakeable

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-26 17:19:26 +02:00 committed by prescientmoon
parent 0fd6baac81
commit 63ce76a552
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -1,19 +1,19 @@
import { terser } from 'rollup-plugin-terser' import { terser } from 'rollup-plugin-terser'
import { resolve } from 'path' import { resolve } from 'path'
import ts from '@wessberg/rollup-plugin-ts' import ts from '@wessberg/rollup-plugin-ts'
import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
const outputDirectory = resolve(__dirname, 'dist') const outputDirectory = resolve(__dirname, 'dist')
const inputFile = resolve(__dirname, 'src/index.ts') const inputFile = resolve(__dirname, 'src/index.ts')
const npmConfig = require(resolve(__dirname, `package.json`))
const external = Object.keys(npmConfig.dependencies || {})
const dev = Boolean(process.env.ROLLUP_WATCH) const dev = Boolean(process.env.ROLLUP_WATCH)
const commonPlugins = [commonjs(), nodeResolve()]
export default [ export default [
{ {
input: inputFile, input: inputFile,
external,
output: [ output: [
{ {
file: `${outputDirectory}/index.cjs.js`, file: `${outputDirectory}/index.cjs.js`,
@ -27,11 +27,10 @@ export default [
name: 'Option' name: 'Option'
} }
], ],
plugins: [ts(), !dev && terser()] plugins: [...commonPlugins, ts(), !dev && terser()]
}, },
{ {
input: inputFile, input: inputFile,
external,
output: [ output: [
{ {
file: `${outputDirectory}/index.esm.js`, file: `${outputDirectory}/index.esm.js`,
@ -40,6 +39,7 @@ export default [
} }
], ],
plugins: [ plugins: [
...commonPlugins,
ts({ ts({
tsconfig: { tsconfig: {
declaration: true, declaration: true,