@openworkers/adapter-sveltekit 0.4.5 → 0.5.0

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -203,9 +203,10 @@ function index_default(options = {}) {
203
203
  return {
204
204
  name,
205
205
  async adapt(builder) {
206
- const dest = options.out ?? "dist";
206
+ const dest = options.outDir ?? "build";
207
207
  const assetsDir = `${dest}/assets`;
208
208
  const functionsEnabled = options.functions ?? false;
209
+ const nodeCompat = options.nodeCompat ?? false;
209
210
  const files = fileURLToPath2(new URL(".", import.meta.url).href);
210
211
  const tmp = builder.getBuildDirectory("openworkers-tmp");
211
212
  builder.rimraf(dest);
@@ -240,24 +241,32 @@ export { Server, manifest, prerendered, base_path };
240
241
  `
241
242
  );
242
243
  const workerDest = `${dest}/_worker.js`;
243
- const libAsyncHooks = posixify(path2.resolve(files, "../src/lib/async-hooks.ts"));
244
+ const libDir = posixify(path2.resolve(files, "../src/lib"));
245
+ const libAsyncHooks = `${libDir}/async-hooks.ts`;
244
246
  await build2({
245
247
  entryPoints: [`${files}/worker.js`],
246
248
  bundle: true,
247
249
  format: "esm",
248
250
  platform: "neutral",
251
+ mainFields: ["module", "main"],
249
252
  outfile: workerDest,
250
253
  alias: {
251
254
  SERVER: entryPoint,
252
255
  MANIFEST: entryPoint,
253
- "node:async_hooks": libAsyncHooks
256
+ "node:async_hooks": libAsyncHooks,
257
+ ...nodeCompat ? {
258
+ "path": `${libDir}/node-path.ts`,
259
+ "fs": `${libDir}/node-fs.ts`,
260
+ "url": `${libDir}/node-url.ts`
261
+ } : {}
254
262
  },
255
263
  external: ["node:*"],
256
264
  minifySyntax: true,
257
265
  minifyIdentifiers: true,
258
266
  treeShaking: true,
259
267
  banner: {
260
- js: `// Generated by ${name} v${version} at ${(/* @__PURE__ */ new Date()).toISOString()}`
268
+ js: `// Generated by ${name} v${version} at ${(/* @__PURE__ */ new Date()).toISOString()}` + (nodeCompat ? `
269
+ globalThis.process = globalThis.process || { env: { NODE_ENV: "production" } };` : "")
261
270
  }
262
271
  });
263
272
  const functions = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openworkers/adapter-sveltekit",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "description": "SvelteKit adapter for OpenWorkers",
5
5
  "keywords": [
6
6
  "adapter",