bare-stow 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.d.ts +2 -2
- package/lib/shim.js +8 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ The bundle imports `bare-stow-runtime`, and the RPC library if a `server` is req
|
|
|
72
72
|
For `bare-sidecar` and `bare-worker`, the harness also exports `connect()`, which takes a sidecar or worker that the host started itself, such as one running a development entry with arguments, and resolves like `start()`. It accepts the same options, except those of the sidecar or worker. As the entry doesn't go through `stow()`, it attaches to the IPC itself, as described in <https://github.com/holepunchto/bare-stow-runtime>:
|
|
73
73
|
|
|
74
74
|
```js
|
|
75
|
-
|
|
75
|
+
const runtime = require('bare-stow-runtime/process')
|
|
76
76
|
|
|
77
77
|
const ipc = runtime.attach(Bare.IPC)
|
|
78
78
|
|
package/index.d.ts
CHANGED
|
@@ -370,7 +370,7 @@ declare namespace stow {
|
|
|
370
370
|
* @throws The language does not support linked addons or assets.
|
|
371
371
|
* @throws Two different assets would link to the same path.
|
|
372
372
|
*/
|
|
373
|
-
function link(
|
|
373
|
+
export function link(
|
|
374
374
|
entries: URL | string | (URL | string)[],
|
|
375
375
|
target: Target | TargetName,
|
|
376
376
|
out: URL | string,
|
|
@@ -381,7 +381,7 @@ declare namespace stow {
|
|
|
381
381
|
* The name of the folder that `stow.link()` writes the assets of the application to, which a Swift
|
|
382
382
|
* application copies into its bundle.
|
|
383
383
|
*/
|
|
384
|
-
const resources: string
|
|
384
|
+
export const resources: string
|
|
385
385
|
|
|
386
386
|
export {
|
|
387
387
|
type Generated,
|
package/lib/shim.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
const javascript = require('./language/javascript')
|
|
2
2
|
const { select } = require('./provider')
|
|
3
3
|
|
|
4
|
-
// The bundle runs in Bare, so its side of every provider is JavaScript.
|
|
4
|
+
// The bundle runs in Bare, so its side of every provider is JavaScript. The
|
|
5
|
+
// shims are CommonJS, which loads in any graph, such as one whose ES modules are
|
|
6
|
+
// converted to CommonJS.
|
|
5
7
|
module.exports = function shim(entry, isolation, server = null) {
|
|
6
8
|
if (server) server = select('RPC library', server, javascript.name)
|
|
7
9
|
|
|
8
10
|
const dir = new URL('./', entry)
|
|
9
|
-
const url = new URL('__main__.
|
|
10
|
-
const serverURL = server ? new URL('__server__.
|
|
11
|
+
const url = new URL('__main__.cjs', dir)
|
|
12
|
+
const serverURL = server ? new URL('__server__.cjs', dir) : null
|
|
11
13
|
|
|
12
14
|
const modules = new Map()
|
|
13
15
|
|
|
14
16
|
if (server) {
|
|
15
17
|
modules.set(
|
|
16
18
|
serverURL.href,
|
|
17
|
-
server.generate({ role: 'server', options: { module: '
|
|
19
|
+
server.generate({ role: 'server', options: { module: 'cjs' } }).source
|
|
18
20
|
)
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
modules.set(
|
|
22
24
|
url.href,
|
|
23
25
|
`\
|
|
24
|
-
|
|
25
|
-
${server ? `
|
|
26
|
+
const runtime = require('${isolation === 'process' ? 'bare-stow-runtime/process' : 'bare-stow-runtime'}')
|
|
27
|
+
${server ? `const server = require(${JSON.stringify(javascript.reference(url, serverURL))})\n` : ''}
|
|
26
28
|
const ipc = runtime.attach(Bare.IPC)
|
|
27
29
|
${server ? '\nconst rpc = server.attach(ipc)\n' : ''}
|
|
28
30
|
ipc.run(() => import(${JSON.stringify(javascript.reference(url, entry))}), ${server ? '{ rpc, ipc }' : 'ipc'})
|