Skip to content

Commit

Permalink
simplify a bit further
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Jul 2, 2021
1 parent 101e0b4 commit be3f395
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tools/build_browser.js
Expand Up @@ -201,7 +201,7 @@ async function buildCore(name, languages, options) {
const header = buildHeader();
let relativePath = "";
const input = {
...(options.format === "es" ? config.rollup.node.input : config.rollup.browser_iife.input),
...config.rollup.core.input,
input: `src/stub.js`
};
input.plugins = [
Expand Down
16 changes: 5 additions & 11 deletions tools/build_config.js
Expand Up @@ -9,13 +9,13 @@ module.exports = {
level: 2
},
rollup: {
node: {
output: { format: "cjs", strict: false, exports: "auto" },
core: {
input: {
plugins: [
cjsPlugin(),
jsonPlugin(),
nodeResolve(),
// TODO: remove with version 12
{
transform: (x) => {
if (/var module/.exec(x)) {
Expand All @@ -27,6 +27,9 @@ module.exports = {
]
}
},
node: {
output: { format: "cjs", strict: false, exports: "auto" }
},
browser_iife: {
input: {
plugins: [
Expand All @@ -41,15 +44,6 @@ module.exports = {
footer: "if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = hljs; }",
interop: false
}
},
browser: {
input: {
plugins: []
},
output: {
format: "es",
interop: false
}
}
},
terser: {
Expand Down
6 changes: 3 additions & 3 deletions tools/build_node.js
Expand Up @@ -45,7 +45,7 @@ async function buildNodeLanguage(language, options) {
const ES_STUB = `${EMIT}
import lang from './%%%%.js';
export default lang;`;
const input = { ...config.rollup.node.input, input: language.path };
const input = { ...config.rollup.core.input, input: language.path };
const output = { ...config.rollup.node.output, file: `${process.env.BUILD_DIR}/lib/languages/${language.name}.js` };
await rollupWrite(input, output);
await fs.writeFile(`${process.env.BUILD_DIR}/lib/languages/${language.name}.js.js`,
Expand All @@ -63,7 +63,7 @@ async function buildNodeLanguage(language, options) {
const EXCLUDE = ["join"];

async function buildESMUtils() {
const input = { ...config.rollup.node.input, input: `src/lib/regex.js` };
const input = { ...config.rollup.core.input, input: `src/lib/regex.js` };
input.plugins = [...input.plugins, {
transform: (code) => {
EXCLUDE.forEach((fn) => {
Expand All @@ -80,7 +80,7 @@ async function buildESMUtils() {
}

async function buildNodeHighlightJS(options) {
const input = { ...config.rollup.node.input, input: `src/highlight.js` };
const input = { ...config.rollup.core.input, input: `src/highlight.js` };
const output = { ...config.rollup.node.output, file: `${process.env.BUILD_DIR}/lib/core.js` };
await rollupWrite(input, output);
if (options.esm) {
Expand Down

0 comments on commit be3f395

Please sign in to comment.