BREAKING CHANGE: All source files converted from JavaScript to TypeScript. - 12 .ts source files with strict types, full EditorOptions/Plugin/Token interfaces - 7 .ts test files, 610 total tests (27 new), 7 suites all passing - tsc --noEmit: 0 errors - rollup-plugin-typescript build: 5 artifacts (UMD/ESM/CJS/Min/DTS) - @babel/preset-typescript for jest - New tsconfig.json, updated babel/jest/rollup configs - Coverage: parser 99.5%, utils 95.7%, themes 96.2%, core 88.8%, plugins 89.5% - Removed types/ folder (types now inline in .ts + auto-generated .d.ts) - Desktop-only, no backward compatibility
116 lines
2.3 KiB
JavaScript
116 lines
2.3 KiB
JavaScript
import resolve from '@rollup/plugin-node-resolve';
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
import terser from '@rollup/plugin-terser';
|
|
import typescript from '@rollup/plugin-typescript';
|
|
import dts from 'rollup-plugin-dts';
|
|
import serve from 'rollup-plugin-serve';
|
|
import livereload from 'rollup-plugin-livereload';
|
|
|
|
const isDev = process.env.ROLLUP_WATCH;
|
|
const isProd = process.env.NODE_ENV === 'production';
|
|
|
|
const basePlugins = [
|
|
resolve(),
|
|
commonjs(),
|
|
typescript({
|
|
tsconfig: './tsconfig.json',
|
|
declaration: false,
|
|
}),
|
|
];
|
|
|
|
const devPlugins = isDev ? [
|
|
serve({
|
|
open: true,
|
|
contentBase: ['site', 'dist'],
|
|
port: 3001,
|
|
}),
|
|
livereload({
|
|
watch: ['src', 'site'],
|
|
}),
|
|
] : [];
|
|
|
|
const terserPlugin = isProd ? [
|
|
terser({
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
pure_funcs: ['console.log', 'console.warn'],
|
|
},
|
|
format: {
|
|
comments: false,
|
|
},
|
|
}),
|
|
] : [];
|
|
|
|
export default [
|
|
// UMD development
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.js',
|
|
format: 'umd',
|
|
name: 'MeEditor',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: [...basePlugins, ...devPlugins],
|
|
},
|
|
// ES Module
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.esm.js',
|
|
format: 'es',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: basePlugins,
|
|
},
|
|
// CommonJS
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.cjs.js',
|
|
format: 'cjs',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: basePlugins,
|
|
},
|
|
// UMD minified
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.min.js',
|
|
format: 'umd',
|
|
name: 'MeEditor',
|
|
exports: 'named',
|
|
sourcemap: false,
|
|
},
|
|
plugins: [
|
|
...basePlugins,
|
|
terser({
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
pure_funcs: ['console.log', 'console.warn'],
|
|
passes: 2,
|
|
},
|
|
format: { comments: false },
|
|
mangle: { toplevel: true },
|
|
}),
|
|
],
|
|
},
|
|
// TypeScript declarations bundle
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.d.ts',
|
|
format: 'es',
|
|
},
|
|
plugins: [
|
|
dts(),
|
|
],
|
|
},
|
|
];
|