1
Fork 0

typescript(monorepo-template): build: basic rollup setup

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2020-05-10 19:47:26 +03:00 committed by prescientmoon
parent eae785adaa
commit c2bf42cee4
Signed by: prescientmoon
SSH key fingerprint: SHA256:WFp/cO76nbarETAoQcQXuV+0h7XJsEsOCI0UsyPIy6U
10 changed files with 2159 additions and 29 deletions

View file

@ -1 +1,3 @@
node_modules
sandbox
packages/*/dist

View file

@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "none"
}

View file

@ -1,6 +1,16 @@
{
"cSpell.words": [
"brotli",
"downlevel",
"filesize",
"hygen",
"pnpm"
"plugin",
"pnpm",
"rollup",
"show",
"size",
"sourcemap",
"ts",
"wessberg"
]
}

View file

@ -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"
},

View file

@ -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"
}
}

View file

@ -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
}

View file

@ -1 +0,0 @@
export const hello = () => console.log("Hello world from the test package!")

File diff suppressed because it is too large Load diff

View 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
})
]
}
]

View 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/**"]
}