Skip to content

Commit b7a08cd

Browse files
committed
fix: treat ESM syntax code as CommonJS if esm is not enabled
closes #621, closes #625
1 parent 25f9556 commit b7a08cd

File tree

1 file changed

+3
-1
lines changed
  • packages/react-native-builder-bob/src/utils

1 file changed

+3
-1
lines changed

packages/react-native-builder-bob/src/utils/compile.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export default async function compile({
6969

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

7577
await Promise.all(

0 commit comments

Comments
 (0)