@vercel/remix-builder 2.0.4 → 2.0.6

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.
@@ -1,3 +1,3 @@
1
1
  import { createRequestHandler } from '@remix-run/server-runtime';
2
- import build from '@remix-run/dev/server-build';
3
- export default createRequestHandler(build);
2
+ import * as build from '@remix-run/dev/server-build';
3
+ export default createRequestHandler(build.default || build);
@@ -1,20 +1,20 @@
1
1
  import {
2
- AbortController as NodeAbortController,
3
2
  createRequestHandler as createRemixRequestHandler,
4
- Headers as NodeHeaders,
5
- Request as NodeRequest,
6
3
  writeReadableStreamToWritable,
7
4
  installGlobals,
8
5
  } from '@remix-run/node';
9
6
 
10
7
  installGlobals();
11
8
 
12
- import build from '@remix-run/dev/server-build';
9
+ import * as build from '@remix-run/dev/server-build';
13
10
 
14
- const handleRequest = createRemixRequestHandler(build, process.env.NODE_ENV);
11
+ const handleRequest = createRemixRequestHandler(
12
+ build.default || build,
13
+ process.env.NODE_ENV
14
+ );
15
15
 
16
16
  function createRemixHeaders(requestHeaders) {
17
- const headers = new NodeHeaders();
17
+ const headers = new Headers();
18
18
 
19
19
  for (const key in requestHeaders) {
20
20
  const header = requestHeaders[key];
@@ -37,7 +37,7 @@ function createRemixRequest(req, res) {
37
37
  const url = new URL(req.url, `${protocol}://${host}`);
38
38
 
39
39
  // Abort action/loaders once we can no longer write a response
40
- const controller = new NodeAbortController();
40
+ const controller = new AbortController();
41
41
  res.on('close', () => controller.abort());
42
42
 
43
43
  const init = {
@@ -50,7 +50,7 @@ function createRemixRequest(req, res) {
50
50
  init.body = req;
51
51
  }
52
52
 
53
- return new NodeRequest(url.href, init);
53
+ return new Request(url.href, init);
54
54
  }
55
55
 
56
56
  async function sendRemixResponse(res, nodeResponse) {
package/dist/index.js CHANGED
@@ -2987,25 +2987,36 @@ function addDependencies(cliType, names, opts = {}) {
2987
2987
  (0, import_build_utils.debug)(` - ${name}`);
2988
2988
  }
2989
2989
  const args = [];
2990
- if (cliType === "npm" || cliType === "pnpm") {
2991
- args.push("install");
2992
- if (opts.saveDev) {
2993
- args.push("--save-dev");
2994
- }
2995
- } else {
2996
- args.push("add");
2997
- if (opts.saveDev) {
2998
- args.push("--dev");
2999
- }
3000
- const yarnVersion = (0, import_child_process.execSync)("yarn -v", { encoding: "utf8" }).trim();
3001
- const isYarnV1 = import_semver.default.satisfies(yarnVersion, "1");
3002
- if (isYarnV1) {
3003
- args.push("--ignore-workspace-root-check");
3004
- }
3005
- }
3006
- if (cliType === "pnpm" && opts.cwd) {
3007
- if ((0, import_fs.existsSync)((0, import_path.join)(opts.cwd, "pnpm-workspace.yaml"))) {
3008
- args.push("--workspace-root");
2990
+ switch (cliType) {
2991
+ case "npm":
2992
+ case "pnpm":
2993
+ args.push("install");
2994
+ if (opts.saveDev) {
2995
+ args.push("--save-dev");
2996
+ }
2997
+ if (cliType === "pnpm" && opts.cwd) {
2998
+ if ((0, import_fs.existsSync)((0, import_path.join)(opts.cwd, "pnpm-workspace.yaml"))) {
2999
+ args.push("--workspace-root");
3000
+ }
3001
+ }
3002
+ break;
3003
+ case "bun":
3004
+ case "yarn":
3005
+ args.push("add");
3006
+ if (opts.saveDev) {
3007
+ args.push("--dev");
3008
+ }
3009
+ if (cliType === "yarn") {
3010
+ const yarnVersion = (0, import_child_process.execSync)("yarn -v", { encoding: "utf8" }).trim();
3011
+ const isYarnV1 = import_semver.default.satisfies(yarnVersion, "1");
3012
+ if (isYarnV1) {
3013
+ args.push("--ignore-workspace-root-check");
3014
+ }
3015
+ }
3016
+ break;
3017
+ default: {
3018
+ const n = cliType;
3019
+ throw new Error(`Unexpected package manager: ${n}`);
3009
3020
  }
3010
3021
  }
3011
3022
  return (0, import_build_utils.spawnAsync)(cliType, args.concat(names), opts);
@@ -3231,7 +3242,9 @@ var build = async ({
3231
3242
  } else {
3232
3243
  await (0, import_build_utils3.runNpmInstall)(entrypointFsDirname, [], spawnOpts, meta, nodeVersion);
3233
3244
  }
3234
- const isHydrogen2 = pkg.dependencies?.["@shopify/remix-oxygen"] || pkg.devDependencies?.["@shopify/remix-oxygen"];
3245
+ const isHydrogen2 = Boolean(
3246
+ pkg.dependencies?.["@shopify/remix-oxygen"] || pkg.devDependencies?.["@shopify/remix-oxygen"]
3247
+ );
3235
3248
  const remixRunDevPath = await ensureResolvable(
3236
3249
  entrypointFsDirname,
3237
3250
  repoRootPath,
@@ -3249,7 +3262,8 @@ var build = async ({
3249
3262
  const { serverEntryPoint, appDirectory } = remixConfig;
3250
3263
  const remixRoutes = Object.values(remixConfig.routes);
3251
3264
  const depsToAdd = [];
3252
- if (!isHydrogen2 && remixRunDevPkg.name !== "@vercel/remix-run-dev") {
3265
+ const remixRunDevPkgVersion = pkg.dependencies?.["@remix-run/dev"] || pkg.devDependencies?.["@remix-run/dev"];
3266
+ if (!isHydrogen2 && remixRunDevPkg.name !== "@vercel/remix-run-dev" && !remixRunDevPkgVersion?.startsWith("https:")) {
3253
3267
  const remixDevForkVersion = resolveSemverMinMax(
3254
3268
  REMIX_RUN_DEV_MIN_VERSION,
3255
3269
  REMIX_RUN_DEV_MAX_VERSION,
@@ -3356,7 +3370,7 @@ var build = async ({
3356
3370
  renamedRemixConfigPath
3357
3371
  )}';
3358
3372
  config.serverBuildTarget = undefined;
3359
- config.serverModuleFormat = 'cjs';
3373
+ config.serverModuleFormat = '${pkg.type === "module" ? "esm" : "cjs"}';
3360
3374
  config.serverPlatform = 'node';
3361
3375
  config.serverBuildPath = undefined;
3362
3376
  config.serverBundles = ${JSON.stringify(serverBundles)};
@@ -3366,7 +3380,7 @@ export default config;`;
3366
3380
  renamedRemixConfigPath
3367
3381
  )}');
3368
3382
  config.serverBuildTarget = undefined;
3369
- config.serverModuleFormat = 'cjs';
3383
+ config.serverModuleFormat = '${pkg.type === "module" ? "esm" : "cjs"}';
3370
3384
  config.serverPlatform = 'node';
3371
3385
  config.serverBuildPath = undefined;
3372
3386
  config.serverBundles = ${JSON.stringify(serverBundles)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/remix-builder",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "homepage": "https://vercel.com/docs",
@@ -19,7 +19,7 @@
19
19
  "ts-morph": "12.0.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@remix-run/dev": "npm:@vercel/remix-run-dev@1.19.3",
22
+ "@remix-run/dev": "npm:@vercel/remix-run-dev@2.0.0",
23
23
  "@types/jest": "27.5.1",
24
24
  "@types/node": "14.18.33",
25
25
  "@types/semver": "7.3.13",