Skip to content

Instantly share code, notes, and snippets.

@lancegliser
Last active December 26, 2019 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lancegliser/a660458df52e7dfe9917185bbb7ddaf3 to your computer and use it in GitHub Desktop.
Save lancegliser/a660458df52e7dfe9917185bbb7ddaf3 to your computer and use it in GitHub Desktop.
A basic roll up config file that allows for typescript and dynamic external dependencies
import typescript from 'rollup-plugin-typescript2'
import pkg from './package.json'
const dependencies = Object.keys(pkg.dependencies || {});
const peerDependencies = Object.keys(pkg.peerDependencies || {});
const external = [...dependencies, ...peerDependencies];
export default {
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
exports: 'named',
sourcemap: true,
},
{
file: pkg.module,
format: 'es',
exports: 'named',
sourcemap: true,
}
],
plugins: [
typescript({
rollupCommonJSResolveHack: true,
clean: true
}),
],
external,
}
{
"name": "@company/scoped-package-test",
"version": "1.0.0",
"description": "Provides a basic constant test private package management options through rollup.",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"types": "dist/src/index.d.ts",
"files": [
"dist"
],
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"build": "npm run-script build:clean && npm run-script build:rollup",
"build:clean": "rimraf dist/*",
"build:rollup": "rollup -c",
"start": "npm run-script build:clean && rollup -cw",
"prepare": "npm t && npm run-script build"
},
"repository": {
"type": "git",
"url": ""
},
"author": "Lance Gliser",
"license": "ISC",
"devDependencies": {
"@types/jest": "^24.0.24",
"jest": "^24.9.0",
"rimraf": "^3.0.0",
"rollup": "^1.27.13",
"rollup-plugin-typescript2": "^0.25.3",
"ts-jest": "^24.2.0",
"tslib": "^1.10.0",
"typescript": "^3.7.3"
}
}
{
"compilerOptions": {
"declaration": true,
"declarationDir": "./dist",
"forceConsistentCasingInFileNames": true,
"module": "es6",
"noImplicitAny": true,
"outDir": "./dist",
"target": "es5",
"removeComments": true,
"moduleResolution": "node"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.test.*"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment