|
1 | 1 | class SpinSdkPlugin { |
2 | 2 | constructor() { |
3 | | - this.externals = { |
4 | | - |
5 | | - |
6 | | - "wasi:filesystem/[email protected]": "wasi:filesystem/[email protected]", |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - "spin:postgres/[email protected]": "spin:postgres/[email protected]", |
17 | | - }; |
| 3 | + this.externals = [ |
| 4 | + /^wasi:.*/, |
| 5 | + /^fermyon:.*/, |
| 6 | + /^spin:.*/, |
| 7 | + ]; |
18 | 8 | } |
19 | 9 |
|
20 | 10 | apply(compiler) { |
21 | 11 | // If externals are already defined, merge them with new externals |
22 | | - if (compiler.options.externals && typeof compiler.options.externals === 'object') { |
23 | | - this.externals = Object.assign({}, compiler.options.externals, this.externals); |
| 12 | + const userExternals = compiler.options.externals; |
| 13 | + |
| 14 | + if (Array.isArray(userExternals)) { |
| 15 | + // Append to the existing array |
| 16 | + compiler.options.externals = [...userExternals, ...this.externals]; |
| 17 | + } else if (typeof userExternals === 'object') { |
| 18 | + // Wrap in an array and add the object as-is |
| 19 | + compiler.options.externals = [userExternals, ...this.externals]; |
| 20 | + } else { |
| 21 | + // Default: Just use our externals |
| 22 | + compiler.options.externals = [...this.externals]; |
24 | 23 | } |
25 | | - compiler.options.externals = this.externals; |
26 | 24 | } |
27 | 25 | } |
28 | 26 |
|
|
0 commit comments