Skip to content

Commit

Permalink
Restore index.js entry point (#10033)
Browse files Browse the repository at this point in the history
This is required for ES module compatibility since it does not support JSON import.
  • Loading branch information
saschanaz authored Apr 22, 2021
1 parent 2444619 commit c321920
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/release-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ async function writeData() {
await fs.writeFile(dest, data);
}

async function writeIndex() {
const dest = path.resolve(directory, 'index.js');
const content = `module.exports = require("./data.json");\n`;
await fs.writeFile(dest, content);
}

// Returns an array of promises for copying of all files that don't need transformation
async function copyFiles() {
for (const file of verbatimFiles) {
Expand All @@ -32,7 +38,7 @@ async function copyFiles() {

function createManifest() {
const full = require('../package.json');
const minimal = { main: 'data.json' };
const minimal = { main: 'index.js' };

const minimalKeys = [
'name',
Expand Down Expand Up @@ -80,6 +86,7 @@ async function main() {

await writeManifest();
await writeData();
await writeIndex();
await copyFiles();

console.log('Data bundle is ready');
Expand Down

0 comments on commit c321920

Please sign in to comment.