Skip to content

Commit

Permalink
fix: make input_schema fully ESM usable 馃槩 (#448)
Browse files Browse the repository at this point in the history
Don't you love CJS/ESM state in nodejs
Needed for apify/apify-cli#477
  • Loading branch information
vladfrangu committed Feb 16, 2024
1 parent 95b728f commit fe75f79
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/input_schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"homepage": "https://apify.com",
"scripts": {
"build": "npm run clean && npm run compile && npm run copy",
"build": "npm run clean && npm run compile && npm run copy && ts-node -T scripts/fix-esm.ts",
"clean": "rimraf ./dist",
"compile": "tsup",
"copy": "ts-node -T ../../scripts/copy.ts"
Expand Down
15 changes: 15 additions & 0 deletions packages/input_schema/scripts/fix-esm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// The fact this is needed makes Vlad cry.
import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';

const file = resolve(__dirname, '..', 'dist', 'esm', 'index.mjs');

const fileContent = readFileSync(file, 'utf8');
const fixed = fileContent
.replace(
'import { parseScript } from "escaya";',
`import escaya from "escaya";
const { parseScript } = escaya;`,
);

writeFileSync(file, fixed);

0 comments on commit fe75f79

Please sign in to comment.