Skip to content

Commit 897cf59

Browse files
committed
add package.json to ES module folder
1 parent a2d7417 commit 897cf59

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/build_node.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const safeImportName = (s) => {
1313
};
1414

1515
async function buildESMIndex(name, languages) {
16-
const header = `import hljs from './core.mjs';`;
16+
const header = `import hljs from './core.js';`;
1717
const footer = "export default hljs;";
1818

1919

@@ -152,15 +152,17 @@ async function buildNode(options) {
152152
install(`./src/styles/${file}`, `styles/${file}`);
153153
install(`./src/styles/${file}`, `scss/${file.replace(".css", ".scss")}`);
154154
});
155-
log("Writing package.json.");
156-
await buildPackageJSON(options);
157155

158156
let languages = await getLanguages();
159157
// filter languages for inclusion in the highlight.js bundle
160158
languages = filter(languages, options.languages);
161-
162159
const common = languages.filter(l => l.categories.includes("common"));
160+
161+
log("Writing package.json.");
162+
await buildPackageJSON(options);
163+
163164
if (options.esm) {
165+
await fs.writeFile(`${process.env.BUILD_DIR}/es/package.json`, `{ "type": "module" }`);
164166
await buildESMIndex("index", languages);
165167
await buildESMIndex("common", common);
166168
await buildESMUtils();

0 commit comments

Comments
 (0)