typescript(monorepo-template): build: basic rollup setup
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
eae785adaa
commit
c2bf42cee4
2
typescript/monorepo-template/.gitignore
vendored
2
typescript/monorepo-template/.gitignore
vendored
|
@ -1 +1,3 @@
|
|||
node_modules
|
||||
sandbox
|
||||
packages/*/dist
|
5
typescript/monorepo-template/.prettierrc
Normal file
5
typescript/monorepo-template/.prettierrc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none"
|
||||
}
|
|
@ -1,6 +1,16 @@
|
|||
{
|
||||
"cSpell.words": [
|
||||
"brotli",
|
||||
"downlevel",
|
||||
"filesize",
|
||||
"hygen",
|
||||
"pnpm"
|
||||
"plugin",
|
||||
"pnpm",
|
||||
"rollup",
|
||||
"show",
|
||||
"size",
|
||||
"sourcemap",
|
||||
"ts",
|
||||
"wessberg"
|
||||
]
|
||||
}
|
|
@ -8,7 +8,11 @@ to: packages/<%= name %>/package.json
|
|||
"keywords": [],
|
||||
"main": "dist/bundle.cjs.js",
|
||||
"module": "dist/bundle.esm.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"browser": "dist/bundle.umd.js",
|
||||
"typings": "./dist/bundle.esm.d.ts",
|
||||
"scripts": {
|
||||
"build": "rollup -c ../../rollup.config.ts"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
|
|
|
@ -18,11 +18,27 @@
|
|||
},
|
||||
"homepage": "https://github.com/Mateiadrielrafael/monorepo-template#readme",
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^11.0.0",
|
||||
"@rollup/plugin-node-resolve": "^6.0.0",
|
||||
"@semantic-release/changelog": "^5.0.1",
|
||||
"@semantic-release/git": "^9.0.0",
|
||||
"@types/chai": "^4.2.7",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "^12.12.21",
|
||||
"@types/sinon": "^7.5.1",
|
||||
"@wessberg/rollup-plugin-ts": "^1.1.83",
|
||||
"chai": "^4.2.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"hygen": "^5.0.3",
|
||||
"mocha": "^6.2.2",
|
||||
"rimraf": "^3.0.0",
|
||||
"rollup": "^1.27.14",
|
||||
"rollup-plugin-filesize": "^6.2.1",
|
||||
"rollup-plugin-terser": "^5.1.3",
|
||||
"semantic-release": "^17.0.7",
|
||||
"semantic-release-monorepo": "^7.0.2"
|
||||
"semantic-release-monorepo": "^7.0.2",
|
||||
"sinon": "^8.0.1",
|
||||
"ts-node": "^8.5.4",
|
||||
"typescript": "^3.8.3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"name": "@monorepo/test",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"main": "dist/bundle.cjs.js",
|
||||
"module": "dist/bundle.esm.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"author": "Matei Adriel",
|
||||
"homepage": "https://github.com/Mateiadrielrafael/monorepo-template#readme",
|
||||
"license": "ISC",
|
||||
"repository": {"type":"git","url":"git+https://github.com/Mateiadrielrafael/monorepo-template.git"},
|
||||
"bugs": {"url":"https://github.com/Mateiadrielrafael/monorepo-temolate/issues"},
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"sideEffects": false
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
export const hello = () => console.log("Hello world from the test package!")
|
File diff suppressed because it is too large
Load diff
59
typescript/monorepo-template/rollup.config.ts
Normal file
59
typescript/monorepo-template/rollup.config.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
import { terser } from 'rollup-plugin-terser'
|
||||
import { resolve } from 'path'
|
||||
import ts from '@wessberg/rollup-plugin-ts'
|
||||
import nodeResolve from '@rollup/plugin-node-resolve'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import filesize from 'rollup-plugin-filesize'
|
||||
|
||||
const packageRoot = process.cwd()
|
||||
const dev = Boolean(process.env.ROLLUP_WATCH)
|
||||
|
||||
const inputFile = resolve(packageRoot, 'src/index.ts')
|
||||
|
||||
const _package = require(resolve(packageRoot, 'package.json'))
|
||||
const packageName = String(_package.name)
|
||||
|
||||
const commonPlugins = [nodeResolve(), commonjs()]
|
||||
|
||||
export default [
|
||||
{
|
||||
input: inputFile,
|
||||
output: [
|
||||
{
|
||||
file: _package.main,
|
||||
format: 'cjs',
|
||||
sourcemap: true
|
||||
},
|
||||
{
|
||||
file: _package.browser,
|
||||
sourcemap: true,
|
||||
format: 'umd',
|
||||
name: packageName[0].toUpperCase() + packageName.substr(1)
|
||||
}
|
||||
],
|
||||
plugins: [...commonPlugins, ts(), !dev && terser()]
|
||||
},
|
||||
{
|
||||
input: inputFile,
|
||||
output: [
|
||||
{
|
||||
file: _package.module,
|
||||
format: 'esm',
|
||||
sourcemap: true
|
||||
}
|
||||
],
|
||||
plugins: [
|
||||
...commonPlugins,
|
||||
ts({
|
||||
tsconfig: {
|
||||
declaration: true,
|
||||
...require(resolve(__dirname, 'tsconfig.json'))['compilerOptions']
|
||||
}
|
||||
}),
|
||||
!dev && terser(),
|
||||
filesize({
|
||||
showBrotliSize: true
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
14
typescript/monorepo-template/tsconfig.json
Normal file
14
typescript/monorepo-template/tsconfig.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"downlevelIteration": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strictBindCallApply": true,
|
||||
"strictNullChecks": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node"
|
||||
},
|
||||
"include": ["packages/*/src/**/*.ts"],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
Loading…
Reference in a new issue