Skip to content

Commit 2cd89c3

Browse files
Bartek Wronavogel76
authored andcommitted
Fix Babel transpile for EXPORT_ES6 by using sourceType module
When EXPORT_ES6 is enabled, makeNodeImport() generates top-level await import() expressions. Babel's transpile step was configured with sourceType 'script', which cannot parse top-level await. This caused test_node_prefix_transpile to fail at compilation. Use sourceType 'module' when EXPORT_ES6 is active so Babel can correctly parse and transpile the ESM output.
1 parent 581bbaa commit 2cd89c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/building.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def version_split(v):
541541
@ToolchainProfiler.profile()
542542
def transpile(filename):
543543
config = {
544-
'sourceType': 'script',
544+
'sourceType': 'module' if settings.EXPORT_ES6 else 'script',
545545
'presets': ['@babel/preset-env'],
546546
'plugins': [],
547547
'targets': {},

0 commit comments

Comments
 (0)