-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: use rollup instead of webpack and esbuild #1701
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ | |
|
||
# prettier ignores | ||
/packages/cst-dts-gen/test/snapshots/**/output.d.ts | ||
|
||
.rollup.cache |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
recursive: true, | ||
require: ["./test/test.config", "source-map-support/register"], | ||
require: ["./test/test.config", "ts-node/register"], | ||
reporter: "spec", | ||
spec: "./lib/test/**/*spec.js" | ||
spec: "./test/**/*spec.ts" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,24 +24,20 @@ | |
}, | ||
"files": [ | ||
"chevrotain.d.ts", | ||
"lib_esm/**/*.mjs", | ||
"lib_esm/**/*.mjs.map", | ||
"lib/src/**/*.js", | ||
"lib/src/**/*.js.map", | ||
"lib/chevrotain.d.ts", | ||
"lib/chevrotain.min.js", | ||
"lib/chevrotain.js", | ||
"lib/*.js", | ||
"lib/*.mjs", | ||
"lib/*.map", | ||
"src/**/*.ts", | ||
"readme.md", | ||
"README.md", | ||
"LICENSE.TXT", | ||
"diagrams/**/*.*", | ||
"CHANGELOG.md" | ||
], | ||
"typings": "./chevrotain.d.ts", | ||
"main": "./lib/src/api.js", | ||
"main": "./lib/chevrotain.js", | ||
"exports": { | ||
"require": "./lib/src/api.js", | ||
"import": "./lib_esm/api_esm.mjs" | ||
"require": "./lib/chevrotain.js", | ||
"import": "./lib/chevrotain.mjs" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
@@ -50,44 +46,40 @@ | |
"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-commonjs": "^21.0.1", | ||
"@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", | ||
"ts-node": "^10.4.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these deps are no longer needed (from previous version with mocha + tsnode) |
||
"tslib": "^2.3.1", | ||
"xregexp": "5.1.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const typescriptPlugin = require("@rollup/plugin-typescript") | ||
const { default: nodeResolvePlugin } = require("@rollup/plugin-node-resolve") | ||
const typescript = require("typescript") | ||
const { terser } = require("rollup-plugin-terser") | ||
const commonjsPlugin = require("@rollup/plugin-commonjs") | ||
|
||
const pkg = require("./package.json") | ||
|
||
module.exports = [ | ||
// no deps | ||
{ | ||
input: "src/api.ts", | ||
output: [ | ||
["commonjs", false], | ||
["es", false] | ||
].map(([format, compress]) => ({ | ||
format: format, | ||
entryFileNames: | ||
"chevrotain" + | ||
(compress ? ".min" : "") + | ||
(format === "es" ? ".mjs" : ".js"), | ||
sourcemap: true, | ||
dir: "lib", | ||
name: "chevrotain", | ||
exports: "named" | ||
})), | ||
external: Object.keys(pkg.dependencies), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not we include everything in the bundle? |
||
plugins: [typescriptPlugin({ typescript })], | ||
onwarn: function (warning, warn) { | ||
if ("THIS_IS_UNDEFINED" === warning.code) return | ||
// if ('CIRCULAR_DEPENDENCY' === warning.code) return | ||
warn(warning) | ||
} | ||
}, | ||
|
||
// bundle | ||
{ | ||
input: "src/api.ts", | ||
output: [ | ||
["es", false, true], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do these combination mean? |
||
["es", true, true], | ||
["umd", false, true], | ||
["umd", true, true] | ||
].map(([format, compress]) => ({ | ||
format: format, | ||
entryFileNames: | ||
"chevrotain-bundle" + | ||
(compress ? ".min" : "") + | ||
(format === "es" ? ".mjs" : ".js"), | ||
sourcemap: true, | ||
dir: "lib", | ||
name: "chevrotain", | ||
exports: "named", | ||
plugins: compress | ||
? [ | ||
terser({ | ||
compress: { | ||
passes: 3, | ||
unsafe: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we know everything works after bundling particularly when using |
||
ecma: 7 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ecma 7 means ECMAScript 2017? or 2016? |
||
}, | ||
toplevel: true, | ||
mangle: { | ||
properties: { regex: /^_/ } | ||
} | ||
}) | ||
] | ||
: [] | ||
})), | ||
external: [], | ||
plugins: [ | ||
typescriptPlugin({ typescript }), | ||
nodeResolvePlugin(), | ||
commonjsPlugin() | ||
], | ||
onwarn: function (warning, warn) { | ||
if ("THIS_IS_UNDEFINED" === warning.code) return | ||
// if ('CIRCULAR_DEPENDENCY' === warning.code) return | ||
warn(warning) | ||
} | ||
} | ||
] |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "build tests and source first, then run built tests" seemed a bit awkward. Also it had problems with wrong source lines in stack traces.
This runs the .ts spec files directly on the .ts source. This should have the advantage that the coverage report is more useful as it applies to the the .ts source. Also fix-coverage-report shouldn't be necessary anymore (?)