Skip to content

Commit 7e26de7

Browse files
committed
rename to export_es6
1 parent 160bd91 commit 7e26de7

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ See docs/process.md for more on how version tagging works.
3636
These are fundamentally incompatible but were previously ignored. (#24849)
3737
- `--modularize` flag was added to `file_packager.py` available when run
3838
standalone, to enable ES6 imports of generated JavaScript code
39+
- `--export-es6` flag was added to `file_packager.py` available when run
40+
standalone, to enable ES6 imports of generated JavaScript code (#24737)
3941

4042
4.0.12 - 08/01/25
4143
-----------------

test/test_other.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,7 +3954,7 @@ def test_file_packager_standalone_modularize(self):
39543954
MESSAGE = 'Remember to build the main file with `-sFORCE_FILESYSTEM` so that it includes support for loading this file package'
39553955

39563956
create_file('data.txt', 'hello data')
3957-
err = self.run_process([FILE_PACKAGER, 'test.data', '--modularize', '--preload', 'data.txt', '--js-output=dataFileLoader.js', '--no-node'], stderr=PIPE).stderr
3957+
err = self.run_process([FILE_PACKAGER, 'test.data', '--export-es6', '--preload', 'data.txt', '--js-output=dataFileLoader.js', '--no-node'], stderr=PIPE).stderr
39583958
self.assertContained(MESSAGE, err)
39593959

39603960
create_file('test.c', '''
@@ -3980,7 +3980,8 @@ def test_file_packager_standalone_modularize(self):
39803980
var module = loadModule();
39813981
module.then(async (module) => {
39823982
loadDataFile(module);
3983-
await sleep(1000);
3983+
// sleep so we don't have to use monitorRunDependencies logic
3984+
await sleep(2000);
39843985
module._test_fun();
39853986
});
39863987
''')

tools/file_packager.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
4242
--export-name=EXPORT_NAME Use custom export name (default is `Module`)
4343
44-
--modularize Wrap generated code inside ES6 exported function
44+
--export-es6 Wrap generated code inside ES6 exported function
4545
4646
--no-force Don't create output if no valid input file is specified.
4747
@@ -131,7 +131,7 @@ def __init__(self):
131131
self.use_preload_plugins = False
132132
self.support_node = True
133133
self.wasm64 = False
134-
self.modularize = False
134+
self.export_es6 = False
135135

136136

137137
class DataFile:
@@ -394,8 +394,8 @@ def main(): # noqa: C901, PLR0912, PLR0915
394394
elif arg == '--no-force':
395395
options.force = False
396396
leading = ''
397-
elif arg == '--modularize':
398-
options.modularize = True
397+
elif arg == '--export-es6':
398+
options.export_es6 = True
399399
leading = ''
400400
elif arg == '--use-preload-cache':
401401
options.use_preload_cache = True
@@ -491,8 +491,8 @@ def main(): # noqa: C901, PLR0912, PLR0915
491491
diagnostics.error('TARGET should not be the same value of --js-output')
492492
return 1
493493

494-
if options.from_emcc and options.modularize:
495-
diagnostics.error('Can\'t use modularize option together with --from-emcc since the code should be embedded '
494+
if options.from_emcc and options.export_es6:
495+
diagnostics.error('Can\'t use --export-es6 option together with --from-emcc since the code should be embedded '
496496
'within emcc\'s code')
497497
return 1
498498

@@ -632,7 +632,7 @@ def generate_js(data_target, data_files, metadata):
632632
if options.from_emcc:
633633
ret = ''
634634
else:
635-
if options.modularize:
635+
if options.export_es6:
636636
ret = 'export default function loadDataFile(Module) {'
637637

638638
else:
@@ -643,7 +643,7 @@ def generate_js(data_target, data_files, metadata):
643643
Module['expectedDataFileDownloads'] ??= 0;
644644
Module['expectedDataFileDownloads']++;'''
645645

646-
if not options.modularize:
646+
if not options.export_es6:
647647
ret += '''
648648
(() => {'''
649649

@@ -1158,7 +1158,7 @@ def generate_js(data_target, data_files, metadata):
11581158
}
11591159
loadPackage(%s);\n''' % json.dumps(metadata)
11601160

1161-
if options.modularize:
1161+
if options.export_es6:
11621162
ret += '\n};\n// END the loadDataFile function\n'
11631163
else:
11641164
ret += '''

0 commit comments

Comments
 (0)