-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
111 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
defaults | ||
not IE 11 | ||
not IE_Mob 11 | ||
maintained node versions |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,8 @@ | ||
import externals from "rollup-plugin-node-externals"; | ||
import typescript from "@rollup/plugin-typescript"; | ||
import babel from "@rollup/plugin-babel"; | ||
import generatePackageJson from "rollup-plugin-generate-package-json"; | ||
import { getPkgJsonBaseContents } from "./script-modules/gen-pkg"; | ||
|
||
import glob from "glob"; | ||
import path from "path"; | ||
|
||
const kvToObj = ([k, v]) => ({ [k]: v }); | ||
|
||
const entryFiles = Object.assign( | ||
{}, | ||
...glob | ||
.sync("src/*.ts") | ||
.map((f) => [path.parse(f).name, f]) | ||
.map(kvToObj), | ||
...glob | ||
.sync("src/*/index.ts") | ||
.map((f) => [path.basename(path.dirname(f)), f]) | ||
.map(kvToObj), | ||
); | ||
|
||
export default { | ||
input: entryFiles, | ||
output: [ | ||
{ dir: "dist", format: "cjs", sourcemap: true }, | ||
{ dir: "dist/es", format: "es", sourcemap: true }, | ||
], | ||
plugins: [ | ||
// https://github.com/Septh/rollup-plugin-node-externals | ||
externals({ | ||
builtins: true, | ||
deps: true, | ||
peerDeps: true, | ||
optDeps: true, | ||
devDeps: false, | ||
}), | ||
// https://github.com/rollup/plugins/tree/master/packages/typescript | ||
typescript({ | ||
tsconfig: "tsconfig.prod.json", | ||
sourceMap: true, | ||
inlineSources: true, | ||
}), | ||
// https://github.com/rollup/plugins/tree/master/packages/babel | ||
babel({ | ||
extensions: [".js", ".jsx", ".es6", ".es", ".mjs", ".ts", ".tsx"], | ||
babelHelpers: "bundled", | ||
}), | ||
// https://github.com/vladshcherbin/rollup-plugin-generate-package-json | ||
generatePackageJson({ | ||
baseContents: getPkgJsonBaseContents, | ||
outputFolder: "dist", | ||
}), | ||
], | ||
}; | ||
import nodeConfig from "./script-modules/rollup-node"; | ||
import bundleConfig from "./script-modules/rollup-bundle"; | ||
|
||
export default [ | ||
// | ||
nodeConfig, | ||
bundleConfig, | ||
]; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { compilePlugins } from "./rollup-common"; | ||
import { terser } from "rollup-plugin-terser"; | ||
|
||
const GLOBAL_NAMESPACE = "ChineseNumbering"; | ||
|
||
const FORMATS = [ | ||
// | ||
"es", | ||
"iife", | ||
"umd", | ||
]; | ||
|
||
function genOutputs(format) { | ||
// https://rollupjs.org/guide/en/#outputname | ||
const name = format === "es" ? undefined : GLOBAL_NAMESPACE; | ||
|
||
return [true, false].map((min) => ({ | ||
format, | ||
sourcemap: true, | ||
file: `dist/bundle/${format}${min ? ".min" : ""}.js`, | ||
name, | ||
plugins: min ? [terser()] : undefined, | ||
})); | ||
} | ||
|
||
export default { | ||
input: "src/index.ts", | ||
output: FORMATS.map(genOutputs).flat(1), | ||
plugins: [ | ||
// | ||
...compilePlugins(), | ||
], | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import typescript from "@rollup/plugin-typescript"; | ||
import babel from "@rollup/plugin-babel"; | ||
|
||
export function compilePlugins() { | ||
return [ | ||
// https://github.com/rollup/plugins/tree/master/packages/typescript | ||
typescript({ | ||
tsconfig: "tsconfig.prod.json", | ||
sourceMap: true, | ||
inlineSources: true, | ||
}), | ||
// https://github.com/rollup/plugins/tree/master/packages/babel | ||
babel({ | ||
extensions: [".js", ".jsx", ".es6", ".es", ".mjs", ".ts", ".tsx"], | ||
babelHelpers: "bundled", | ||
}), | ||
]; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import externals from "rollup-plugin-node-externals"; | ||
import generatePackageJson from "rollup-plugin-generate-package-json"; | ||
import { compilePlugins } from "./rollup-common"; | ||
import { getPkgJsonBaseContents } from "./gen-pkg"; | ||
|
||
import glob from "glob"; | ||
import path from "path"; | ||
|
||
const kvToObj = ([k, v]) => ({ [k]: v }); | ||
|
||
const entryFiles = Object.assign( | ||
{}, | ||
...glob | ||
.sync("src/*.ts") | ||
.map((f) => [path.parse(f).name, f]) | ||
.map(kvToObj), | ||
...glob | ||
.sync("src/*/index.ts") | ||
.map((f) => [path.basename(path.dirname(f)), f]) | ||
.map(kvToObj), | ||
); | ||
|
||
const chunkFileNames = "_chunks/[name]-[hash].js"; | ||
|
||
export default { | ||
input: entryFiles, | ||
output: [ | ||
{ dir: "dist", format: "cjs", sourcemap: true, chunkFileNames }, | ||
{ dir: "dist/es", format: "es", sourcemap: true, chunkFileNames }, | ||
], | ||
plugins: [ | ||
// https://github.com/Septh/rollup-plugin-node-externals | ||
externals({ | ||
builtins: true, | ||
deps: true, | ||
peerDeps: true, | ||
optDeps: true, | ||
devDeps: false, | ||
}), | ||
...compilePlugins(), | ||
// https://github.com/vladshcherbin/rollup-plugin-generate-package-json | ||
generatePackageJson({ | ||
baseContents: getPkgJsonBaseContents, | ||
outputFolder: "dist", | ||
}), | ||
], | ||
}; |