Skip to content

Commit

Permalink
🏗 use Rollup.js itself instead of bili abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorLuizC committed Aug 15, 2020
1 parent ed46b7d commit a96ed16
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 2,348 deletions.
23 changes: 0 additions & 23 deletions .bilirc.ts

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ dist/
# Generated type declarations.
types/

# Transpiled sources and their source-maps.
src/**/*.js
src/**/*.js.map

# PNPM and NPM's lockfile.
# We're using Yarn and it provide its own lockfile.
package-lock.json
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"scripts": {
"test": "yarn run test:lint && yarn run test:unit",
"test:unit": "jest",
"test:lint": "prettier **/* --check",
"build": "bili",
"test:lint": "prettier src/**/*.ts --check",
"build": "yarn run build:transpile && yarn run build:bundle",
"build:transpile": "tsc --project ./tsconfig.build.json",
"build:bundle": "rollup --config rollup.config.js",
"prepublishOnly": "yarn run test && yarn run build"
},
"files": [
Expand Down Expand Up @@ -49,11 +51,12 @@
},
"homepage": "https://github.com/VitorLuizC/normalize-text#readme",
"devDependencies": {
"@rollup/plugin-node-resolve": "^9.0.0",
"@types/jest": "^26.0.7",
"bili": "^5.0.5",
"jest": "~26.1.0",
"prettier": "^2.0.5",
"rollup-plugin-typescript2": "^0.27.1",
"rollup": "^2.25.0",
"rollup-plugin-terser": "^7.0.0",
"ts-jest": "^26.1.4",
"typescript": "^3.9.7"
},
Expand Down
57 changes: 57 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// @ts-check

import { terser } from 'rollup-plugin-terser';
import resolve from '@rollup/plugin-node-resolve';

/**
* Options of Rollup.js.
* @type {Array.<import('rollup').RollupOptions>}
*/
const options = [
{
input: './src/index.js',
external: ['@bitty/pipe'],
output: [
getOutputOption({
format: 'commonjs',
file: './dist/index.js',
}),
getOutputOption({
format: 'esm',
file: './dist/index.esm.js',
}),
],
},
{
input: './src/index.js',
plugins: [resolve()],
output: [
getOutputOption({
format: 'umd',
name: 'normalizeText',
file: './dist/index.umd.js',
}),
getOutputOption({
format: 'umd',
name: 'normalizeText',
file: './dist/index.umd.min.js',
plugins: [terser()],
}),
],
},
];

/**
* Creates an output option.
* @param {import('rollup').OutputOptions} options
* @returns {import('rollup').OutputOptions}
*/
function getOutputOption(options) {
return {
...options,
exports: 'named',
sourcemap: true,
};
}

export default options;
9 changes: 4 additions & 5 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
"compilerOptions": {
// Build settings
"newLine": "LF",
"noEmitOnError": true,
"outDir": "dist/",
"charset": "utf-8",
"sourceMap": true,

// Type declarations settings
"declaration": true,
"declarationDir": "types/",
"declarationDir": "./types",
"declarationMap": true
},
"include": ["src/"],
"exclude": ["src/**/*.spec.ts"]
"include": ["./src"],
"exclude": ["./src/**/*.spec.ts"]
}
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true
},
"include": [".bilirc.ts", "src/"]
}
}
Loading

0 comments on commit a96ed16

Please sign in to comment.