Skip to content

Commit

Permalink
chore: use Node protocol imports (remix-run#7000)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Dalgleish <[email protected]>
  • Loading branch information
MichaelDeBoey and markdalgleish authored Aug 1, 2023
1 parent 3ed7f73 commit 7dfbd88
Show file tree
Hide file tree
Showing 106 changed files with 172 additions and 172 deletions.
2 changes: 1 addition & 1 deletion docs/guides/migrating-react-router-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Let's start by creating two new files:
<docs-info>All of your app code in Remix will live in an `app` directory by convention. If your existing app uses a directory with the same name, rename it to something like `src` or `old-app` to differentiate as we migrate to Remix.</docs-info>

```tsx filename=app/entry.server.tsx
import { PassThrough } from "stream";
import { PassThrough } from "node:stream";

import type {
AppLoadContext,
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/resource-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const action = async ({ request }: ActionArgs) => {
Resource routes can be used to handle webhooks. For example, you can create a webhook that receives notifications from GitHub when a new commit is pushed to a repository:

```tsx
import crypto from "crypto";
import crypto from "node:crypto";

import type { ActionArgs } from "@remix-run/node"; // or cloudflare/deno
import { json } from "@remix-run/node"; // or cloudflare/deno
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Let's take a dive into how to accomplish this.
First, to enable streaming with React 18, you'll update your `entry.server.tsx` file to use `renderToPipeableStream`. Here's a simple (and incomplete) version of that:

```tsx filename=app/entry.server.tsx lines=[1,10,20,27,32,37]
import { PassThrough } from "stream";
import { PassThrough } from "node:stream";

import { Response } from "@remix-run/node"; // or cloudflare/deno
import type {
Expand Down Expand Up @@ -131,7 +131,7 @@ export default function handleRequest(
This handles errors and properly disables streaming for bots which you typically want to force waiting, so you can display all the content for SEO purposes.

```tsx filename=app/entry.server.tsx
import { PassThrough } from "stream";
import { PassThrough } from "node:stream";

import { Response } from "@remix-run/node"; // or cloudflare/deno
import type {
Expand Down
2 changes: 1 addition & 1 deletion docs/other-api/adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = createRequestHandler({
Here's an example with Netlify:

```ts
const path = require("path");
const path = require("node:path");

const {
createRequestHandler,
Expand Down
4 changes: 2 additions & 2 deletions integration/cf-compiler-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "@playwright/test";
import fs from "fs/promises";
import path from "path";
import fs from "node:fs/promises";
import path from "node:path";
import shell from "shelljs";
import glob from "glob";

Expand Down
12 changes: 6 additions & 6 deletions integration/compiler-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from "path";
import path from "node:path";
import fse from "fs-extra";
import { test, expect } from "@playwright/test";
import { PassThrough } from "stream";
import { PassThrough } from "node:stream";

import {
createFixture,
Expand Down Expand Up @@ -55,7 +55,7 @@ test.describe("compiler", () => {
`,
"app/routes/built-ins.jsx": js`
import { useLoaderData } from "@remix-run/react";
import * as path from "path";
import * as path from "node:path";
export let loader = () => {
return path.join("test", "file.txt");
Expand All @@ -67,7 +67,7 @@ test.describe("compiler", () => {
`,
"app/routes/built-ins-polyfill.jsx": js`
import { useLoaderData } from "@remix-run/react";
import * as path from "path";
import * as path from "node:path";
export default function BuiltIns() {
return <div id="built-ins-polyfill">{path.join("test", "file.txt")}</div>;
Expand Down Expand Up @@ -228,7 +228,7 @@ test.describe("compiler", () => {
let routeModule = await fixture.getBrowserAsset(
fixture.build.assets.routes["routes/built-ins"].module
);
// does not include `import bla from "path"` in the output bundle
// does not include `import bla from "node:path"` in the output bundle
expect(routeModule).not.toMatch(/from\s*"path/);
});

Expand All @@ -247,7 +247,7 @@ test.describe("compiler", () => {
let routeModule = await fixture.getBrowserAsset(
fixture.build.assets.routes["routes/built-ins-polyfill"].module
);
// does not include `import bla from "path"` in the output bundle
// does not include `import bla from "node:path"` in the output bundle
expect(routeModule).not.toMatch(/from\s*"path/);
});

Expand Down
2 changes: 1 addition & 1 deletion integration/defer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ test.describe("aborted", () => {
////////////////////////////////////////////////////////////////////////////
files: {
"app/entry.server.tsx": js`
import { PassThrough } from "stream";
import { PassThrough } from "node:stream";
import type { AppLoadContext, EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
Expand Down
2 changes: 1 addition & 1 deletion integration/deno-compiler-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "@playwright/test";
import * as fse from "fs-extra";
import path from "path";
import path from "node:path";
import shell from "shelljs";
import glob from "glob";

Expand Down
4 changes: 2 additions & 2 deletions integration/deterministic-build-output-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";
import globby from "globby";
import fs from "fs";
import path from "path";
import fs from "node:fs";
import path from "node:path";

import type { FixtureInit } from "./helpers/create-fixture";
import { createFixtureProject, js, css } from "./helpers/create-fixture";
Expand Down
6 changes: 3 additions & 3 deletions integration/file-uploads-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from "fs/promises";
import * as path from "path";
import * as fs from "node:fs/promises";
import * as path from "node:path";
import { test, expect } from "@playwright/test";

import { createFixture, createAppFixture, js } from "./helpers/create-fixture";
Expand All @@ -14,7 +14,7 @@ test.describe("file-uploads", () => {
fixture = await createFixture({
files: {
"app/fileUploadHandler.js": js`
import * as path from "path";
import * as path from "node:path";
import {
unstable_composeUploadHandlers as composeUploadHandlers,
unstable_createFileUploadHandler as createFileUploadHandler,
Expand Down
2 changes: 1 addition & 1 deletion integration/helpers/cleanup.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import spawn from "cross-spawn";

if (process.env.CI) {
Expand Down
2 changes: 1 addition & 1 deletion integration/helpers/playwright-fixture.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cp from "child_process";
import cp from "node:child_process";
import type { Page, Response, Request } from "@playwright/test";
import { test } from "@playwright/test";
import cheerio from "cheerio";
Expand Down
2 changes: 1 addition & 1 deletion integration/hmr-log-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let fixture = (options: { appPort: number; devPort: number }): FixtureInit => ({
}),

"server.js": js`
let path = require("path");
let path = require("node:path");
let express = require("express");
let { createRequestHandler } = require("@remix-run/express");
let { logDevReady } = require("@remix-run/node");
Expand Down
2 changes: 1 addition & 1 deletion integration/hmr-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let fixture = (options: { appPort: number; devPort: number }): FixtureInit => ({
}),

"server.js": js`
let path = require("path");
let path = require("node:path");
let express = require("express");
let { createRequestHandler } = require("@remix-run/express");
let { broadcastDevReady } = require("@remix-run/node");
Expand Down
4 changes: 2 additions & 2 deletions integration/server-source-maps-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "@playwright/test";
import path from "path";
import fsp from "fs/promises";
import path from "node:path";
import fsp from "node:fs/promises";

import { createFixture, js } from "./helpers/create-fixture";
import type { Fixture } from "./helpers/create-fixture";
Expand Down
2 changes: 1 addition & 1 deletion integration/upload-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import { test, expect } from "@playwright/test";

import { PlaywrightFixture } from "./helpers/playwright-fixture";
Expand Down
2 changes: 1 addition & 1 deletion jest/buildRemix.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import { spawn } from "cross-spawn";

function buildRemix(dir) {
Expand Down
10 changes: 5 additions & 5 deletions packages/create-remix/__tests__/create-remix-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ChildProcessWithoutNullStreams } from "child_process";
import { spawn } from "child_process";
import { tmpdir } from "os";
import path from "path";
import { pathToFileURL } from "url";
import type { ChildProcessWithoutNullStreams } from "node:child_process";
import { spawn } from "node:child_process";
import { tmpdir } from "node:os";
import path from "node:path";
import { pathToFileURL } from "node:url";
import fse from "fs-extra";
import semver from "semver";
import stripAnsi from "strip-ansi";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");

module.exports = ({ rootDirectory }) => {
fs.writeFileSync(
Expand Down
4 changes: 2 additions & 2 deletions packages/create-remix/__tests__/fixtures/tar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const tar = require("tar-fs");
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");

let files = fs.readdirSync(__dirname);
let dirs = files.filter((file) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/create-remix/__tests__/github-mocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as nodePath from "path";
import fsp from "fs/promises";
import * as nodePath from "node:path";
import fsp from "node:fs/promises";
import invariant from "tiny-invariant";
import type { setupServer } from "msw/node";
import { rest } from "msw";
Expand Down
4 changes: 2 additions & 2 deletions packages/create-remix/__tests__/msw.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import fsp from "fs/promises";
import path from "node:path";
import fsp from "node:fs/promises";
import { setupServer } from "msw/node";
import { rest } from "msw";

Expand Down
2 changes: 1 addition & 1 deletion packages/create-remix/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const json = require("@rollup/plugin-json").default;
const babel = require("@rollup/plugin-babel").default;
const nodeResolve = require("@rollup/plugin-node-resolve").default;
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-architect/__tests__/server-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fsp from "fs/promises";
import path from "path";
import fsp from "node:fs/promises";
import path from "node:path";
import lambdaTester from "lambda-tester";
import type { APIGatewayProxyEventV2 } from "aws-lambda";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as crypto from "crypto";
import * as crypto from "node:crypto";
import type {
SessionData,
SessionStorage,
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-cloudflare-pages/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const babel = require("@rollup/plugin-babel").default;
const nodeResolve = require("@rollup/plugin-node-resolve").default;

Expand Down
2 changes: 1 addition & 1 deletion packages/remix-cloudflare-workers/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const babel = require("@rollup/plugin-babel").default;
const nodeResolve = require("@rollup/plugin-node-resolve").default;

Expand Down
2 changes: 1 addition & 1 deletion packages/remix-cloudflare/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const babel = require("@rollup/plugin-babel").default;
const nodeResolve = require("@rollup/plugin-node-resolve").default;
const copy = require("rollup-plugin-copy");
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-css-bundle/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const babel = require("@rollup/plugin-babel").default;
const nodeResolve = require("@rollup/plugin-node-resolve").default;
const copy = require("rollup-plugin-copy");
Expand Down
8 changes: 4 additions & 4 deletions packages/remix-dev/__tests__/cli-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import childProcess from "child_process";
import os from "os";
import path from "path";
import util from "util";
import childProcess from "node:child_process";
import os from "node:os";
import path from "node:path";
import util from "node:util";
import fse from "fs-extra";
import semver from "semver";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PassThrough } from "stream";
import { PassThrough } from "node:stream";
import type { AppLoadContext, EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");

module.exports = ({ rootDirectory }) => {
fs.writeFileSync(
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/__tests__/fixtures/tar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const tar = require("tar-fs");
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");

let files = fs.readdirSync(__dirname);
let dirs = files.filter((file) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/__tests__/github-mocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as nodePath from "path";
import fsp from "fs/promises";
import * as nodePath from "node:path";
import fsp from "node:fs/promises";
import invariant from "tiny-invariant";
import type { setupServer } from "msw/node";
import { rest } from "msw";
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/__tests__/init-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as os from "os";
import * as path from "path";
import * as os from "node:os";
import * as path from "node:path";
import * as fse from "fs-extra";
import stripAnsi from "strip-ansi";

Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/__tests__/msw.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import fsp from "fs/promises";
import path from "node:path";
import fsp from "node:fs/promises";
import { setupServer } from "msw/node";
import { rest } from "msw";

Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/__tests__/readConfig-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from "path";
import path from "node:path";

import type { RemixConfig } from "../config";
import { readConfig } from "../config";
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/__tests__/useJavascript-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tmpdir } from "os";
import path from "path";
import { tmpdir } from "node:os";
import path from "node:path";
import glob from "fast-glob";
import fs from "fs-extra";

Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/__tests__/utils/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import execa from "execa";
import path from "path";
import path from "node:path";
import glob from "fast-glob";
import fse from "fs-extra";

Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/__tests__/utils/withApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os from "os";
import path from "path";
import os from "node:os";
import path from "node:path";
import fse from "fs-extra";

const retry = async (
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import { execSync } from "child_process";
import * as path from "node:path";
import { execSync } from "node:child_process";
import * as fse from "fs-extra";
import getPort, { makeRange } from "get-port";
import prettyMs from "pretty-ms";
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";

import type { Context } from "./context";
import * as CSS from "./css";
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/css/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import * as fse from "fs-extra";
import type * as esbuild from "esbuild";
import postcss from "postcss";
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/css/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { builtinModules as nodeBuiltins } from "module";
import { builtinModules as nodeBuiltins } from "node:module";
import * as esbuild from "esbuild";

import type { RemixConfig } from "../../config";
Expand Down
Loading

0 comments on commit 7dfbd88

Please sign in to comment.