bare-stow 0.3.1 → 0.3.2

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 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
- import runtime from 'bare-stow-runtime/process'
75
+ const runtime = require('bare-stow-runtime/process')
76
76
 
77
77
  const ipc = runtime.attach(Bare.IPC)
78
78
 
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__.mjs', dir)
10
- const serverURL = server ? new URL('__server__.mjs', dir) : null
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: 'esm' } }).source
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
- import runtime from '${isolation === 'process' ? 'bare-stow-runtime/process' : 'bare-stow-runtime'}'
25
- ${server ? `import * as server from ${JSON.stringify(javascript.reference(url, serverURL))}\n` : ''}
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'})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-stow",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Module bundling and harness generation for Bare",
5
5
  "exports": {
6
6
  "./package": "./package.json",