Skip to content

Commit

Permalink
[build] Test building a "use strict" safe package
Browse files Browse the repository at this point in the history
- Adds a test to the CI pipeline that builds a "typical" consolidated
  Highlight.js package from the full NPM source and then checks that
  that build actually executes without errors

Related to highlightjs#2247.
  • Loading branch information
joshgoebel committed Nov 1, 2019
1 parent 41794bb commit f7009ad
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 2 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ node_js:
- "lts/*"
- "node"
env:
-
# we current only test "use strict" for our NPM builds
- TEST_BUILDING_USE_STRICT_BUNDLE=1
- BROWSER=1
- BROWSER=1 NOCOMPRESS=1
script:
Expand All @@ -22,6 +23,14 @@ script:
node tools/build.js $BUILD_PARAMS
# test that our build is "use strict" safe for use with packaging
# systems importing our source thru ES6 modules (rollup, etc.)
if [ "x$TEST_BUILDING_USE_STRICT_BUNDLE" = "x1" ]; then
./node_modules/.bin/rollup -c test/builds/rollup_import_via_commonjs.js
node build/bundle.js || exit 1
rm build/bundle.js
fi
if [ "x$BROWSER" = "x1" ]; then
npm run test-browser
else
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ New styles:
none.

Improvements:
- ehh(build) Add CI check for building a "use strict" safe rollup package from NPM builds (#2247) [Josh Goebel][]
- enhance(css) Improve @rule highlighting, including properties (#2241) [Josh Goebel][]
- enhance(css) Improve highlighting of numbers inside expr/func `calc(2px+3px)` (#2241)
- enhance(scss) Pull some of the CSS improvements back into SCSS (#2241)
Expand Down
88 changes: 88 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"node": "*"
},
"devDependencies": {
"bluebird": "^3.5.5",
"cli-table": "^0.3.1",
"colors": "^1.1.2",
"bluebird": "^3.5.5",
"commander": "^4.0.0",
"del": "^5.1.0",
"gear": "github:highlightjs/gear",
Expand All @@ -42,6 +42,8 @@
"jsdom": "^15.1.1",
"lodash": "^4.17.15",
"mocha": "^6.2.0",
"rollup": "^1.26.2",
"rollup-plugin-commonjs": "^10.1.0",
"should": "^13.2.3",
"tiny-worker": "^2.3.0"
}
Expand Down
11 changes: 11 additions & 0 deletions test/builds/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
This file is used by import_via_commonjs.js to build a single "package"
and acts as a sanity check that all our code is "use strict" safe
See .travis.yml
*/

import hljs from '../../build/lib/index.js';

hljs.highlight("cpp","/* test */")
console.log("Rollup built package works.")

0 comments on commit f7009ad

Please sign in to comment.