@@ -41,15 +41,23 @@ const runtimePlatformArch = () => `${process.platform}${runtimeLibc()}-${process
41
41
42
42
/* istanbul ignore next */
43
43
const buildPlatformArch = ( ) => {
44
+ if ( isEmscripten ( ) ) {
45
+ return 'wasm32' ;
46
+ }
44
47
/* eslint camelcase: ["error", { allow: ["^npm_config_"] }] */
45
48
const { npm_config_arch, npm_config_platform, npm_config_libc } = process . env ;
46
- return `${ npm_config_platform || process . platform } ${ npm_config_libc || runtimeLibc ( ) } -${ npm_config_arch || process . arch } ` ;
49
+ const libc = typeof npm_config_libc === 'string' ? npm_config_libc : runtimeLibc ( ) ;
50
+ return `${ npm_config_platform || process . platform } ${ libc } -${ npm_config_arch || process . arch } ` ;
47
51
} ;
48
52
49
53
const buildSharpLibvipsIncludeDir = ( ) => {
50
54
try {
51
- return require ( '@img/sharp-libvips-dev/include' ) ;
52
- } catch { }
55
+ return require ( `@img/sharp-libvips-dev-${ buildPlatformArch ( ) } /include` ) ;
56
+ } catch {
57
+ try {
58
+ return require ( '@img/sharp-libvips-dev/include' ) ;
59
+ } catch { }
60
+ }
53
61
/* istanbul ignore next */
54
62
return '' ;
55
63
} ;
@@ -64,12 +72,22 @@ const buildSharpLibvipsCPlusPlusDir = () => {
64
72
65
73
const buildSharpLibvipsLibDir = ( ) => {
66
74
try {
67
- return require ( `@img/sharp-libvips-${ buildPlatformArch ( ) } /lib` ) ;
68
- } catch { }
75
+ return require ( `@img/sharp-libvips-dev-${ buildPlatformArch ( ) } /lib` ) ;
76
+ } catch {
77
+ try {
78
+ return require ( `@img/sharp-libvips-${ buildPlatformArch ( ) } /lib` ) ;
79
+ } catch { }
80
+ }
69
81
/* istanbul ignore next */
70
82
return '' ;
71
83
} ;
72
84
85
+ /* istanbul ignore next */
86
+ const isEmscripten = ( ) => {
87
+ const { CC } = process . env ;
88
+ return Boolean ( CC && CC . endsWith ( '/emcc' ) ) ;
89
+ } ;
90
+
73
91
const isRosetta = ( ) => {
74
92
/* istanbul ignore next */
75
93
if ( process . platform === 'darwin' && process . arch === 'x64' ) {
@@ -81,7 +99,7 @@ const isRosetta = () => {
81
99
82
100
/* istanbul ignore next */
83
101
const spawnRebuild = ( ) =>
84
- spawnSync ( ' node-gyp rebuild --directory=src' , {
102
+ spawnSync ( ` node-gyp rebuild --directory=src ${ isEmscripten ( ) ? '--nodedir=emscripten' : '' } ` , {
85
103
...spawnSyncOptions ,
86
104
stdio : 'inherit'
87
105
} ) . status ;
0 commit comments