From 316484ffbc7169b5277a836852d7e4f8b2cc245d Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sat, 25 Apr 2020 17:39:56 -0400 Subject: [PATCH 1/6] (build) browser build is CommonJS and IIFE (global) - dropping support for AMD, which we never truly supported in the first place Resolves #2505 --- tools/build_config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/build_config.js b/tools/build_config.js index 6ce035be96..ce38ab41ea 100644 --- a/tools/build_config.js +++ b/tools/build_config.js @@ -29,7 +29,8 @@ module.exports = { }, output: { name: "hljs", - format: "umd", + format: "iife", + footer: "if (typeof module !== 'undefined') { module.exports = hljs; }", interop: false, } }, From d0fb87cc77873ba2985f55727d949c8c363acc60 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sat, 25 Apr 2020 17:46:58 -0400 Subject: [PATCH 2/6] use more specific code from rollups UMD header --- tools/build_config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_config.js b/tools/build_config.js index ce38ab41ea..c32efe993c 100644 --- a/tools/build_config.js +++ b/tools/build_config.js @@ -30,7 +30,7 @@ module.exports = { output: { name: "hljs", format: "iife", - footer: "if (typeof module !== 'undefined') { module.exports = hljs; }", + footer: "if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = hljs; }", interop: false, } }, From e0af5472441e00a76dcdc217acf0bea4200f3793 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sun, 26 Apr 2020 12:38:23 -0400 Subject: [PATCH 3/6] add test to make sure browser build works as commonJS module --- .travis.yml | 2 ++ test/builds/browser_build_as_commonjs.js | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 test/builds/browser_build_as_commonjs.js diff --git a/.travis.yml b/.travis.yml index fa61a6a0e9..67fd1364cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,5 +29,7 @@ script: npm run test else npm run test-browser + # our browser build should also work fine as a Node.js CommonJS module + node test/builds/browser_build_as_commonjs.js fi sudo: false # Use container-based architecture diff --git a/test/builds/browser_build_as_commonjs.js b/test/builds/browser_build_as_commonjs.js new file mode 100644 index 0000000000..4315df2ff0 --- /dev/null +++ b/test/builds/browser_build_as_commonjs.js @@ -0,0 +1,6 @@ +const hljs = require("../../build/highlight"); + +let major = parseInt(majorVersion=hljs.versionString.split(".")) +if (major != 10) { + process.exit(1) +} From 444b506c542b010990c39b58b79ee361e95e81fe Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sun, 26 Apr 2020 12:51:38 -0400 Subject: [PATCH 4/6] add notes to changelog --- CHANGES.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a36b69e06f..b6a40ff534 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,16 @@ ## Version 10.0.1 +Brower build: + +- [Issue](https://github.com/highlightjs/highlight.js/issues/2505) (bug) Fix: Version 10 fails to load as CommonJS module. (#2511) [Josh Goebel][] +- [Issue](https://github.com/highlightjs/highlight.js/issues/2505) (removal) AMD module loading support has been removed. (#2511) [Josh Goebel][] + + Parser Engine Changes: -- (bug) Fix sublanguage with no relevance score (#2506) [Josh Goebel][] +- [Issue](https://github.com/highlightjs/highlight.js/issues/2504) (bug) Fix sublanguage with no relevance score (#2506) [Josh Goebel][] + + [Josh Goebel]: https://github.com/yyyc514 From 32829ff14820edd12a259c61c5da69b92fc5e85d Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sun, 3 May 2020 13:52:22 -0400 Subject: [PATCH 5/6] Update CHANGES.md --- CHANGES.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 9aa49b8110..afa1831b3f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,7 +30,7 @@ Language Improvements: [Vania Kucher]: https://github.com/qWici -## Version 10.0.1 +## Version 10.0.2 (pending) Brower build: @@ -43,6 +43,14 @@ Parser Engine Changes: - [Issue](https://github.com/highlightjs/highlight.js/issues/2504) (bug) Fix sublanguage with no relevance score (#2506) [Josh Goebel][] +[Josh Goebel]: https://github.com/yyyc514 + + +## Version 10.0.1 + +Parser Engine Changes: + +- (bug) Fix sublanguage with no relevance score (#2506) [Josh Goebel][] [Josh Goebel]: https://github.com/yyyc514 From 888d0730ea8e218c4a29a756a131990b9217d86a Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Sun, 3 May 2020 13:53:13 -0400 Subject: [PATCH 6/6] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index afa1831b3f..8d9201c218 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -40,7 +40,7 @@ Brower build: Parser Engine Changes: -- [Issue](https://github.com/highlightjs/highlight.js/issues/2504) (bug) Fix sublanguage with no relevance score (#2506) [Josh Goebel][] +- ... [Josh Goebel]: https://github.com/yyyc514