File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -1958,6 +1958,8 @@ def check_human_readable_list(items):
1958
1958
exit_with_error ('NODE_CODE_CACHING requires sync compilation (WASM_ASYNC_COMPILATION=0)' )
1959
1959
if not shared .Settings .target_environment_may_be ('node' ):
1960
1960
exit_with_error ('NODE_CODE_CACHING only works in node, but target environments do not include it' )
1961
+ if shared .Settings .SINGLE_FILE :
1962
+ exit_with_error ('NODE_CODE_CACHING saves a file on the side and is not compatible with SINGLE_FILE' )
1961
1963
1962
1964
# safe heap in asm.js uses the js optimizer (in wasm-only mode we can use binaryen)
1963
1965
if shared .Settings .SAFE_HEAP and not shared .Building .is_wasm_only ():
Original file line number Diff line number Diff line change @@ -1069,6 +1069,7 @@ function createWasm() {
1069
1069
// to load ok, but we do actually recompile the binary every time).
1070
1070
var cachedCodeFile = '{{{ WASM_BINARY_FILE }}}.' + v8 . cachedDataVersionTag ( ) + '.cached' ;
1071
1071
cachedCodeFile = locateFile ( cachedCodeFile ) ;
1072
+ if ( ! nodeFS ) nodeFS = require ( 'fs' ) ;
1072
1073
var hasCached = nodeFS . existsSync ( cachedCodeFile ) ;
1073
1074
if ( hasCached ) {
1074
1075
#if RUNTIME_LOGGING
@@ -1077,7 +1078,7 @@ function createWasm() {
1077
1078
try {
1078
1079
module = v8 . deserialize ( nodeFS . readFileSync ( cachedCodeFile ) ) ;
1079
1080
} catch ( e ) {
1080
- err ( 'NODE_CODE_CACHING: failed to deserialize, bad cache file?' ) ;
1081
+ err ( 'NODE_CODE_CACHING: failed to deserialize, bad cache file? (' + cachedCodeFile + ') ') ;
1081
1082
// Save the new compiled code when we have it.
1082
1083
hasCached = false ;
1083
1084
}
Original file line number Diff line number Diff line change @@ -836,10 +836,9 @@ var NODERAWFS = 0;
836
836
// The V8 version used in node is included in the cache name so that we don't
837
837
// try to load cached code from another version, which fails silently (it seems
838
838
// to load ok, but we do actually recompile).
839
- // * This requires a somewhat recent node, but unclear what version, see
840
- // https://github.com/nodejs/node/issues/18265#issuecomment-471237531
841
- // * This option requires WASM_ASYNC_COMPILATION=0 (we load and save code
842
- // in the sync compilation path for simplicity).
839
+ // * The only version known to work for sure is node 12.9.1, as this has
840
+ // regressed, see
841
+ // https://github.com/nodejs/node/issues/18265#issuecomment-622971547
843
842
// * The default location of the .cached files is alongside the wasm binary,
844
843
// as mentioned earlier. If that is in a read-only directory, you may need
845
844
// to place them elsewhere. You can use the locateFile() hook to do so.
You can’t perform that action at this time.
0 commit comments