Created
May 30, 2023 15:27
-
-
Save OssiPesonen/675d8342079bd6ee62aee0194ab3d4f6 to your computer and use it in GitHub Desktop.
Rollup bundling test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "rollup-test", | |
"version": "1.0.0", | |
"description": "", | |
"types": "dist/typings/index.d.ts", | |
"type": "module", | |
"exports": { | |
".": { | |
"import": "./dist/esm/index.min.mjs", | |
"require": "./dist/cjs/index.min.cjs", | |
"types": "./dist/typings/index.d.ts" | |
} | |
}, | |
"main": "./dist/cjs/index.min.cjs", | |
"module": "./dist/esm/index.min.mjs", | |
"source": "./src/index.ts", | |
"files": [ | |
"dist/", | |
"src/" | |
], | |
"scripts": { | |
"build": "rimraf dist && rollup --config --sourcemap" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"@rollup/plugin-commonjs": "^25.0.0", | |
"@rollup/plugin-node-resolve": "15.0.2", | |
"@rollup/plugin-terser": "^0.4.3", | |
"@wessberg/rollup-plugin-ts": "2.0.4", | |
"rimraf": "^5.0.1", | |
"rollup": "^3.23.0", | |
"rollup-plugin-dts": "^5.3.0", | |
"rollup-plugin-typescript2": "^0.34.1", | |
"typescript": "^5.0.4" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resolve from '@rollup/plugin-node-resolve'; | |
import terser from '@rollup/plugin-terser'; | |
import typescript from 'rollup-plugin-typescript2'; | |
import pkg from './package.json' assert { type: "json" }; | |
const minifiedOutputs = [ | |
{ | |
file: pkg.exports['.'].import, | |
format: 'esm', | |
plugins: [terser()], | |
}, | |
{ | |
file: pkg.exports['.'].require, | |
format: 'cjs', | |
plugins: [terser()], | |
}, | |
]; | |
const unminifiedOutputs = minifiedOutputs.map(({ file, ...rest }) => ({ | |
...rest, | |
file: file.replace('.min.', '.'), | |
plugins: [], | |
})); | |
const commonPlugins = [ | |
typescript({ | |
clean: true, | |
useTsconfigDeclarationDir: true, | |
tsconfigOverride: { | |
noEmit: false, | |
sourceMap: true, | |
compilerOptions: { | |
lib: ['dom', 'es6'] | |
} | |
} | |
}) | |
]; | |
export default [ | |
{ | |
input: './src/index.ts', | |
output: [...unminifiedOutputs, ...minifiedOutputs], | |
plugins: [ | |
...commonPlugins, | |
resolve(), | |
], | |
external: [/^@babel\/runtime\//], | |
}, | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "ES2017", | |
"allowSyntheticDefaultImports": true, | |
"esModuleInterop": true, | |
"sourceMap": true, | |
"declaration": true, | |
"declarationDir": "./dist/typings", | |
"moduleResolution": "node", | |
"noImplicitAny": true, | |
"downlevelIteration": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment