Skip to content

Commit

Permalink
fix: treat ESM syntax code as CommonJS if esm is not enabled
Browse files Browse the repository at this point in the history
closes #621, closes #625
  • Loading branch information
satya164 committed Sep 8, 2024
1 parent 25f9556 commit b7a08cd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react-native-builder-bob/src/utils/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export default async function compile({

await fs.mkdirp(output);
await fs.writeJSON(path.join(output, 'package.json'), {
type: modules === 'commonjs' ? 'commonjs' : 'module',
// Treat code with ESM syntax as CommonJS if `esm` is not enabled
// This maintain compatibility with code written for CommonJS
type: modules === 'commonjs' || !esm ? 'commonjs' : 'module',
});

await Promise.all(
Expand Down

0 comments on commit b7a08cd

Please sign in to comment.