Skip to content

Commit

Permalink
chore: use rollup instead of webpack and esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
NaridaL committed Nov 3, 2021
1 parent 719598c commit 6da2a23
Show file tree
Hide file tree
Showing 9 changed files with 2,758 additions and 3,441 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ yarn-error.log
/examples/implementation_languages/typescript/*.js
/examples/implementation_languages/coffeescript/*.js
/examples/parser/minification/gen/

.rollup.cache
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@

# prettier ignores
/packages/cst-dts-gen/test/snapshots/**/output.d.ts

.rollup.cache
8 changes: 6 additions & 2 deletions packages/chevrotain/.mocharc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
recursive: true,
require: ["./test/test.config", "source-map-support/register"],
require: [
"./test/test.config",
"source-map-support/register",
"ts-node/register"
],
reporter: "spec",
spec: "./lib/test/**/*spec.js"
spec: "./test/**/*spec.ts"
}
1 change: 1 addition & 0 deletions packages/chevrotain/nyc.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
exclude: [
"lib/test/**/*.*",
"test/test.config.js",
"test",
// unable to exclude specific deperacted function in this file
// due to transpilation step "moving" the ignore comments around.
"lib/src/parse/errors_public.js"
Expand Down
31 changes: 13 additions & 18 deletions packages/chevrotain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
"CHANGELOG.md"
],
"typings": "./chevrotain.d.ts",
"main": "./lib/src/api.js",
"main": "./lib/chevrotain.js",
"module": "./lib/chevrotain.mjs",
"exports": {
"require": "./lib/src/api.js",
"import": "./lib_esm/api_esm.mjs"
"require": "./lib/chevrotain.js",
"import": "./lib/chevrotain.mjs"
},
"repository": {
"type": "git",
Expand All @@ -50,44 +51,38 @@
"homepage": "https://chevrotain.io/docs/",
"scripts": {
"---------- CI FLOWS --------": "",
"build": "npm-run-all clean compile bundle",
"build": "npm-run-all clean bundle",
"test": "npm-run-all coverage",
"version": "tsc ./src/version.ts --outDir lib/src && node ./scripts/version-update.js",
"---------- DEV FLOWS --------": "",
"watch": "tsc -w",
"unit-tests": "mocha",
"quick-build": "tsc && yarn run bundle",
"quick-build": "yarn run bundle",
"---------- BUILD STEPS --------": "",
"clean": "shx rm -rf coverage dev lib lib_esm",
"compile": "tsc && node ./scripts/fix-coverage-report.js && npm-run-all gen-esm-wrapper",
"compile:watch": "tsc -w",
"gen-esm-wrapper": "gen-esm-wrapper . ./lib_esm/api_esm.mjs",
"coverage": "nyc mocha",
"---------- BUNDLING --------": "",
"bundle": "npm-run-all bundle:**",
"bundle:regular": "webpack --config webpack_release.config.js",
"bundle:min": "webpack --config webpack_release_min.config.js",
"bundle:esm:regular": "esbuild ./lib/src/api.js --bundle --sourcemap --format=esm --outfile=lib_esm/chevrotain.mjs",
"bundle:esm:min": "esbuild ./lib/src/api.js --bundle --minify --format=esm --sourcemap --outfile=lib_esm/chevrotain.min.mjs"
"bundle": "rollup --config",
"bundle:watch": "rollup --config --watch"
},
"dependencies": {
"@chevrotain/types": "^9.1.0",
"@chevrotain/utils": "^9.1.0",
"regexp-to-ast": "0.5.0"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-typescript": "^8.3.0",
"@types/sinon-chai": "3.2.5",
"error-stack-parser": "2.0.6",
"esbuild": "0.13.8",
"gen-esm-wrapper": "1.1.3",
"gitty": "3.7.2",
"jsdom": "18.0.0",
"jsonfile": "6.1.0",
"require-from-string": "2.0.2",
"rollup": "^2.59.0",
"rollup-plugin-terser": "^7.0.2",
"sinon": "11.1.2",
"sinon-chai": "3.7.0",
"webpack": "5.59.1",
"webpack-cli": "4.9.1",
"tslib": "^2.3.1",
"xregexp": "5.1.0"
}
}
46 changes: 46 additions & 0 deletions packages/chevrotain/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const typescriptPlugin = require("@rollup/plugin-typescript")
const nodeResolvePlugin = require("@rollup/plugin-node-resolve")
const typescript = require("typescript")
const { terser } = require("rollup-plugin-terser")

module.exports = {
input: "src/api.ts",
output: [
["es", false],
["es", true],
["umd", false],
["umd", true]
].map(([format, compress]) => ({
format: format,
entryFileNames:
"chevrotain" +
(compress ? ".min" : "") +
(format === "es" ? ".mjs" : ".js"),
sourcemap: true,
dir: "lib",
name: "chevrotain",
exports: "named",
plugins: compress
? [
terser({
compress: {
passes: 3,
unsafe: true,
ecma: 7
},
toplevel: true,
mangle: {
properties: { regex: /^_/ }
}
})
]
: []
})),
external: {},
plugins: typescriptPlugin({ typescript }),
onwarn: function (warning, warn) {
if ("THIS_IS_UNDEFINED" === warning.code) return
// if ('CIRCULAR_DEPENDENCY' === warning.code) return
warn(warning)
}
}
30 changes: 0 additions & 30 deletions packages/chevrotain/scripts/fix-coverage-report.js

This file was deleted.

1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"target": "ES5",
"composite": true,
"newLine": "lf",
"module": "CommonJS",
"removeComments": false,
"sourceMap": true,
Expand Down

0 comments on commit 6da2a23

Please sign in to comment.