File tree 3 files changed +10
-5
lines changed 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 86
86
set (REMOVE_THREAD_LOCAL sed -i.bak -e "s:thread_local::g" glue.cpp)
87
87
endif ()
88
88
89
- # Replace '("ReplaceWithImport"' with 'import( ' in the generated JS code to workaround a bug in emscripten
89
+ # Replace 'replace_by_import' by 'import' in the generated JS code to workaround a bug in emscripten
90
90
# See: https://github.com/jrouwe/JoltPhysics.js/issues/245
91
- set (REPLACE_IMPORT sed -i -e "s:( \" ReplaceWithImport \" + :import( :g" )
91
+ set (REPLACE_IMPORT sed -i -e "s:replace_by_import :import:g" )
92
92
93
93
# Enable SIMD flags
94
94
if (ENABLE_SIMD)
@@ -136,6 +136,9 @@ set(EMCC_ARGS
136
136
--extern-pre-js ${JOLT_FRONT_MATTER_FILE}
137
137
--post-js glue.js
138
138
--closure=1
139
+ --closure-args="--dynamic_import_alias=replace_by_import"
140
+ --closure-args="--externs"
141
+ --closure-args="${CMAKE_CURRENT_SOURCE_DIR} /extern-import.js"
139
142
${MULTI_THREADED_FLAG}
140
143
--post-js ${CMAKE_CURRENT_SOURCE_DIR} /helpers.js
141
144
${MEMORY_GROWTH_FLAG}
Original file line number Diff line number Diff line change
1
+ // A hack to not have to use 'import' in multi-threaded.js
2
+ // See: https://github.com/jrouwe/JoltPhysics.js/issues/245
3
+ var replace_by_import = ( a ) => { } ;
Original file line number Diff line number Diff line change @@ -4,9 +4,8 @@ if (ENVIRONMENT_IS_PTHREAD) {
4
4
invokeEntryPoint = ( ptr , arg ) => {
5
5
if ( arg . script ) {
6
6
// Workaround for bug: https://github.com/jrouwe/JoltPhysics.js/issues/245
7
- // '("ReplaceWithImport"+arg.script)' should be 'import(arg.script)'
8
- // This gets replaced by sed during the build process.
9
- ( "ReplaceWithImport" + arg . script ) . then ( module => {
7
+ // `replace_by_import` gets replaced by `import`
8
+ replace_by_import ( arg . script ) . then ( module => {
10
9
module . default ( Module , arg . params ) . then ( ( ) => _invokeEntryPoint ( ptr , arg . value ) ) ;
11
10
} )
12
11
} else {
You can’t perform that action at this time.
0 commit comments