@orochibraru/svelte-smol 1.5.0 → 1.5.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 +6 -3
- package/index.ts +14 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,13 +60,16 @@ build/
|
|
|
60
60
|
└── prerendered/
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Dependencies stay external, so ship `node_modules` next to `build/` (or anywhere
|
|
64
|
-
up the tree) and start it with:
|
|
65
|
-
|
|
66
63
|
```bash
|
|
67
64
|
bun run ./build/index.js
|
|
68
65
|
```
|
|
69
66
|
|
|
67
|
+
Pure-JS dependencies are still bundled into `index.js`. A native addon can't be,
|
|
68
|
+
so its `require` stays in the output and resolves from `node_modules` at runtime
|
|
69
|
+
(looked up from `index.js`'s own location, so the working directory doesn't
|
|
70
|
+
matter). Ship `node_modules` for those — a production install is enough, since
|
|
71
|
+
everything that got bundled needn't be there.
|
|
72
|
+
|
|
70
73
|
Everything else — env vars, the `healthcheck` binary, `serveAssets`,
|
|
71
74
|
instrumentation — works the same.
|
|
72
75
|
|
package/index.ts
CHANGED
|
@@ -17,11 +17,12 @@ export interface AdapterOptions {
|
|
|
17
17
|
name?: string;
|
|
18
18
|
/**
|
|
19
19
|
* Compile the server to a single standalone executable with
|
|
20
|
-
* `bun build --compile`. Turn this off to emit a plain `index.js`
|
|
21
|
-
* instead, run with `bun run build/index.js
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* `bun build --compile`. Turn this off to emit a plain `build/index.js`
|
|
21
|
+
* bundle instead, run with `bun run build/index.js`. Pure-JS dependencies
|
|
22
|
+
* are still bundled in; a native (`.node`) addon can't be, so it resolves
|
|
23
|
+
* from `node_modules` at runtime — which a `bun` process can do and a
|
|
24
|
+
* compiled binary can't. This is the only way to ship `sharp`, `sqlite3`
|
|
25
|
+
* and the like. The `healthcheck` binary is still compiled either way.
|
|
25
26
|
* @default true
|
|
26
27
|
*/
|
|
27
28
|
compile?: boolean;
|
|
@@ -109,8 +110,8 @@ const templates = fileURLToPath(new URL("./templates", import.meta.url));
|
|
|
109
110
|
* true`); loading the config alone works under Node too.
|
|
110
111
|
*
|
|
111
112
|
* With {@link AdapterOptions.compile | `compile: false`} it emits a plain
|
|
112
|
-
* `build/index.js` bundle instead (
|
|
113
|
-
*
|
|
113
|
+
* `build/index.js` bundle instead (run with `bun`), the only way to ship a
|
|
114
|
+
* native (`.node`) addon.
|
|
114
115
|
*
|
|
115
116
|
* Output, all written to {@link AdapterOptions.out | `out`}:
|
|
116
117
|
*
|
|
@@ -284,16 +285,17 @@ export default function adapter(options: AdapterOptions = {}): Adapter {
|
|
|
284
285
|
|
|
285
286
|
const bundleServer = async (entrypoint: string) => {
|
|
286
287
|
builder.log.minor("Bundling index.js");
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
//
|
|
290
|
-
//
|
|
288
|
+
// Same bundle as the compiled binary, just emitted as a file. Every
|
|
289
|
+
// pure-JS dependency is inlined; a native (`.node`) addon can't be,
|
|
290
|
+
// so its `require` stays in the output and resolves from
|
|
291
|
+
// `node_modules` at runtime — which is exactly what a plain `bun`
|
|
292
|
+
// process (unlike a compiled binary) can do. Ship `node_modules`
|
|
293
|
+
// for those; anything fully bundled needn't be installed.
|
|
291
294
|
check(
|
|
292
295
|
await Bun.build({
|
|
293
296
|
entrypoints: [entrypoint],
|
|
294
297
|
target: "bun",
|
|
295
298
|
format: "esm",
|
|
296
|
-
packages: "external",
|
|
297
299
|
minify,
|
|
298
300
|
sourcemap: sourcemap ? "linked" : "none",
|
|
299
301
|
outdir: out,
|