From 3131469fc2522d1bd03e019018ef727230c511d4 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Tue, 27 Apr 2021 18:45:37 +0200 Subject: [PATCH] rollup-plugin-esbuild --- package.json | 6 ++---- rollup.config.js | 33 ++++++++++----------------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index c7bfce0..4e7b9ed 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ }, "devDependencies": { "@microsoft/api-extractor": "^7.14.0", - "@rollup/plugin-buble": "^0.21.3", "@rollup/plugin-replace": "^2.3.3", "@types/three": "^0.127.1", "@typescript-eslint/eslint-plugin": "^4.22.0", @@ -18,6 +17,7 @@ "@vue/eslint-config-standard": "^5.1.2", "@vue/eslint-config-typescript": "^7.0.0", "cannon": "^0.6.2", + "esbuild": "^0.11.15", "eslint": "^7.7.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-node": "^11.1.0", @@ -25,9 +25,7 @@ "eslint-plugin-standard": "^4.0.1", "eslint-plugin-vue": "^7.9.0", "gsap": "^3.5.1", - "rollup-plugin-terser": "^7.0.2", - "rollup-plugin-typescript2": "^0.30.0", - "rollup-plugin-vue": "^6.0.0-beta.11", + "rollup-plugin-esbuild": "^4.1.0", "stats.js": "0.17.0", "three": "^0.127", "tslib": "^2.2.0", diff --git a/rollup.config.js b/rollup.config.js index e585f48..02f0ada 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,11 +1,6 @@ -import path from 'path' -import vue from 'rollup-plugin-vue' -import typescript from 'rollup-plugin-typescript2' +// import vue from 'rollup-plugin-vue' +import esbuild from 'rollup-plugin-esbuild' import replace from '@rollup/plugin-replace' -import { terser } from "rollup-plugin-terser" - -// ensure TS checks only once for each build -let hasTSChecked = false const input = 'src/export.ts' @@ -40,20 +35,12 @@ const cdnReplaces = { delimiters: ['', ''], } -function createConfig(format, output, plugins = []) { - const tsPlugin = typescript({ - check: false, // !hasTSChecked, - cacheRoot: path.resolve(__dirname, 'node_modules/.tscache'), - tsconfigOverride: { - compilerOptions: { - sourceMap: false, // !hasTSChecked, - declaration: false, // !hasTSChecked, - declarationMap: false, // !hasTSChecked, - }, - include: [input], - }, +function createConfig(format, output, plugins = [], minify = false) { + const tsPlugin = esbuild({ + sourceMap: true, + minify, + target: 'es2019', }) - hasTSChecked = true return { input, @@ -65,8 +52,8 @@ function createConfig(format, output, plugins = []) { sourcemap: true, }, plugins: [ + // vue(), tsPlugin, - vue(), ...plugins, ], } @@ -74,8 +61,8 @@ function createConfig(format, output, plugins = []) { export default [ createConfig('es', { file: 'build/trois.module.cdn.js' }, [replace(cdnReplaces)]), - createConfig('es', { file: 'build/trois.module.cdn.min.js' }, [replace(cdnReplaces), terser()]), + createConfig('es', { file: 'build/trois.module.cdn.min.js' }, [replace(cdnReplaces)], true), createConfig('es', { file: 'build/trois.module.js' }), - createConfig('es', { file: 'build/trois.module.min.js' }, [terser()]), + createConfig('es', { file: 'build/trois.module.min.js' }, [], true), createConfig('cjs', { file: 'build/trois.js' }), ]