Skip to content

Commit

Permalink
change to use @wessberg/rollup-plugin-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sasaplus1 committed Mar 8, 2021
1 parent 0e1ea75 commit c2cf15d
Show file tree
Hide file tree
Showing 4 changed files with 1,241 additions and 57 deletions.
21 changes: 13 additions & 8 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');

const commonjs = require('@rollup/plugin-commonjs');
const { default: nodeResolve } = require('@rollup/plugin-node-resolve');
const typescript = require('rollup-plugin-typescript');
const ts = require('@wessberg/rollup-plugin-ts');

const meta = require('./package.json');

Expand Down Expand Up @@ -50,13 +50,18 @@ module.exports = function (config) {
rollupPreprocessor: {
plugins: [
nodeResolve(),
typescript({
inlineSourceMap: true,
newLine: 'lf',
strict: true,
target: 'ES5'
}),
commonjs()
commonjs(),
ts({
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
inlineSourceMap: true,
module: 'ESNext',
sourceMap: false,
target: 'ES5'
};
}
})
],
output: {
format: 'iife',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@types/type-detect": "^4.0.1",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"@wessberg/rollup-plugin-ts": "^1.3.8",
"benchmark": "^2.1.4",
"eslint": "^7.21.0",
"eslint-config-prettier": "^8.1.0",
Expand All @@ -38,7 +39,6 @@
"prettier": "^2.2.1",
"rollup": "^2.40.0",
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript": "^1.0.1",
"typescript": "^4.2.3"
},
"engines": {
Expand Down
87 changes: 66 additions & 21 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript';
import ts from '@wessberg/rollup-plugin-ts';

import meta from './package.json';

Expand All @@ -18,12 +18,15 @@ if (process.env.build === 'esm') {
plugins: [
nodeResolve(),
commonjs(),
typescript({
module: 'ESNext',
newLine: 'lf',
strict: true,
target: 'ESNext',
outDir: './dist/esm'
ts({
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
declaration: false,
module: 'ESNext',
outDir: './dist/esm'
};
}
})
]
});
Expand All @@ -44,18 +47,15 @@ if (process.env.build === 'umd') {
].join('\n');

const terserOptions = {
ecma: 2020,
compress: {
passes: 2
},
output: {
preamble: banner
}
};

const typescriptOptions = {
newLine: 'lf',
sourceMap: true,
strict: true,
target: 'ES2017'
};

config.push(
{
input: './index.ts',
Expand All @@ -64,14 +64,22 @@ if (process.env.build === 'umd') {
file: `./dist/umd/${meta.name}.legacy.js`,
format: 'umd',
name: meta.name,
// NOTE: break sourcemap
// https://github.com/rollup/rollup/wiki/Troubleshooting#sourcemap-is-likely-to-be-incorrect
sourcemap: true
},
plugins: [
nodeResolve(),
commonjs(),
typescript({ ...typescriptOptions, target: 'ES5' })
ts({
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
declaration: false,
outDir: './dist/umd',
sourceMap: false,
target: 'ES5'
};
}
})
]
},
{
Expand All @@ -86,8 +94,21 @@ if (process.env.build === 'umd') {
plugins: [
nodeResolve(),
commonjs(),
typescript({ ...typescriptOptions, sourceMap: false, target: 'ES5' }),
terser(terserOptions)
ts({
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
declaration: false,
outDir: './dist/umd',
sourceMap: false,
target: 'ES5'
};
}
}),
terser({
...terserOptions,
ecma: 5
})
]
},
{
Expand All @@ -99,7 +120,21 @@ if (process.env.build === 'umd') {
name: meta.name,
sourcemap: true
},
plugins: [nodeResolve(), commonjs(), typescript(typescriptOptions)]
plugins: [
nodeResolve(),
commonjs(),
ts({
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
declaration: false,
module: 'ESNext',
outDir: './dist/umd',
sourceMap: false
};
}
})
]
},
{
input: './index.ts',
Expand All @@ -113,7 +148,17 @@ if (process.env.build === 'umd') {
plugins: [
nodeResolve(),
commonjs(),
typescript({ ...typescriptOptions, sourceMap: false }),
ts({
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
declaration: false,
module: 'ESNext',
outDir: './dist/umd',
sourceMap: false
};
}
}),
terser(terserOptions)
]
}
Expand Down
Loading

0 comments on commit c2cf15d

Please sign in to comment.