Skip to content

Commit

Permalink
Merge branch 'dev' into AL-1898
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewLeedham committed Jul 13, 2022
2 parents a9798ff + 3c6c798 commit d74933f
Show file tree
Hide file tree
Showing 41 changed files with 1,578 additions and 1,046 deletions.
6 changes: 6 additions & 0 deletions .changeset/fast-yaks-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"remix": patch
"@remix-run/react": patch
---

feat(remix-react): add WebSocket reconnect to `LiveReload`
5 changes: 5 additions & 0 deletions .changeset/slimy-avocados-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/vercel": patch
---

feat(remix-vercel): add support for `@vercel/node` v2
5 changes: 5 additions & 0 deletions .changeset/yellow-flowers-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

update serverBareModulesPlugin warning to use full import path - say dependency isn't available in node_modules instead of package.json
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ module.exports = {
"plugin:markdown/recommended",
],
plugins: ["markdown"],
overrides: [
{
files: ["rollup.config.js"],
rules: {
"import/no-extraneous-dependencies": 0,
},
},
],
};
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,4 @@
- zachdtaylor
- zainfathoni
- zhe
- garand
70 changes: 62 additions & 8 deletions integration/compiler-test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import path from "path";
import fs from "fs/promises";
import { test, expect } from "@playwright/test";
import { PassThrough } from "stream";

import {
createFixture,
createAppFixture,
js,
json,
createFixtureProject,
} from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture";
Expand Down Expand Up @@ -134,6 +136,14 @@ test.describe("compiler", () => {
module: "./esm/index.js",
sideEffects: false,
}),
"node_modules/@org/package/sub-package/index.js": js`
module.exports.submodule = require("./submodule.js");
`,
"node_modules/@org/package/sub-package/submodule.js": js`
module.exports = function submodule() {
return "package-with-submodule";
}
`,
"node_modules/@org/package/sub-package/esm/package.json": json({
type: "module",
sideEffects: false,
Expand All @@ -146,14 +156,6 @@ test.describe("compiler", () => {
return "package-with-submodule";
}
`,
"node_modules/@org/package/sub-package/index.js": js`
module.exports.submodule = require("./submodule.js");
`,
"node_modules/@org/package/sub-package/submodule.js": js`
module.exports = function submodule() {
return "package-with-submodule";
}
`,
},
});

Expand Down Expand Up @@ -320,4 +322,56 @@ test.describe("compiler", () => {
expect(magicRemix).toContain(name);
}
});

test.describe("serverBareModulesPlugin", () => {
test("warns when a module isn't installed", async () => {
let buildOutput: string;
let buildStdio = new PassThrough();

await expect(() =>
createFixtureProject({
buildStdio,
files: {
"app/routes/index.jsx": js`
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import notInstalledMain from "some-not-installed-module";
import { notInstalledSub } from "some-not-installed-module/sub";
export function loader() {
return json({ main: notInstalledMain(), sub: notInstalledSub() });
}
export default function Index() {
let data = useLoaderData();
return null;
}
`,
},
})
).rejects.toThrowError("Build failed, check the output above");

let chunks: Buffer[] = [];
buildOutput = await new Promise<string>((resolve, reject) => {
buildStdio.on("error", (error) => {
reject(error);
});
buildStdio.on("data", (chunk) => {
chunks.push(Buffer.from(chunk));
});
buildStdio.on("end", () => {
resolve(Buffer.concat(chunks).toString("utf8"));
});
});

let importer = path.join("app", "routes", "index.jsx");

expect(buildOutput).toContain(
`The path "some-not-installed-module" is imported in ${importer} but "some-not-installed-module" was not found in your node_modules. Did you forget to install it?`
);
expect(buildOutput).toContain(
`The path "some-not-installed-module/sub" is imported in ${importer} but "some-not-installed-module/sub" was not found in your node_modules. Did you forget to install it?`
);
});
});
});
14 changes: 6 additions & 8 deletions integration/helpers/create-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export async function createFixtureProject(init: FixtureInit): Promise<string> {
{ overwrite: true }
);
if (init.setup) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let setupSpawn = spawnSync(
"node",
["node_modules/@remix-run/dev/dist/cli.js", "setup", init.setup],
Expand Down Expand Up @@ -178,26 +177,25 @@ function build(projectDir: string, buildStdio?: Writable, sourcemap?: boolean) {
if (sourcemap) {
buildArgs.push("--sourcemap");
}
let buildSpawn = spawnSync("node", buildArgs, {
cwd: projectDir,
});
let buildSpawn = spawnSync("node", buildArgs, { cwd: projectDir });

// These logs are helpful for debugging. Remove comments if needed.
// console.log("spawning @remix-run/dev/cli.js `build`:\n");
// console.log(" STDOUT:");
// console.log(" " + buildSpawn.stdout.toString("utf-8"));
// console.log(" STDERR:");
// console.log(" " + buildSpawn.stderr.toString("utf-8"));
if (buildSpawn.error || buildSpawn.status) {
console.error(buildSpawn.stderr.toString("utf-8"));
throw buildSpawn.error || new Error(`Build failed, check the output above`);
}

if (buildStdio) {
buildStdio.write(buildSpawn.stdout.toString("utf-8"));
buildStdio.write(buildSpawn.stderr.toString("utf-8"));
buildStdio.end();
}

if (buildSpawn.error || buildSpawn.status) {
console.error(buildSpawn.stderr.toString("utf-8"));
throw buildSpawn.error || new Error(`Build failed, check the output above`);
}
}

async function writeTestFiles(init: FixtureInit, dir: string) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@octokit/rest": "^18.12.0",
"@playwright/test": "1.20.2",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@testing-library/cypress": "^8.0.2",
"@testing-library/jest-dom": "^5.16.2",
Expand Down
10 changes: 9 additions & 1 deletion packages/create-remix/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
module.exports = {
rules: {
// we have an example where we need this
"no-undef": "off",
"no-undef": 0,
},
overrides: [
{
files: ["rollup.config.js"],
rules: {
"no-undef": 2,
},
},
],
};
7 changes: 7 additions & 0 deletions packages/create-remix/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { getCliConfig } = require("../../rollup.utils");
const { name: packageName, version } = require("./package.json");

/** @returns {import("rollup").RollupOptions[]} */
module.exports = function rollup() {
return [getCliConfig({ packageName, version })];
};
6 changes: 6 additions & 0 deletions packages/remix-architect/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { getAdapterConfig } = require("../../rollup.utils");

/** @returns {import("rollup").RollupOptions[]} */
module.exports = function rollup() {
return [getAdapterConfig("architect")];
};
44 changes: 44 additions & 0 deletions packages/remix-cloudflare-pages/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const path = require("path");
const babel = require("@rollup/plugin-babel").default;
const nodeResolve = require("@rollup/plugin-node-resolve").default;

const {
copyToPlaygrounds,
createBanner,
getAdapterConfig,
getOutputDir,
isBareModuleId,
} = require("../../rollup.utils");
const { name: packageName, version } = require("./package.json");

/** @returns {import("rollup").RollupOptions[]} */
module.exports = function rollup() {
let sourceDir = "packages/remix-cloudflare-pages";
let outputDir = getOutputDir(packageName);
let outputDist = path.join(outputDir, "dist");

return [
{
external(id) {
return isBareModuleId(id);
},
input: `${sourceDir}/index.ts`,
output: {
banner: createBanner("@remix-run/cloudflare-pages", version),
dir: `${outputDist}/esm`,
format: "esm",
preserveModules: true,
},
plugins: [
babel({
babelHelpers: "bundled",
exclude: /node_modules/,
extensions: [".ts", ".tsx"],
}),
nodeResolve({ extensions: [".ts", ".tsx"] }),
copyToPlaygrounds(),
],
},
getAdapterConfig("cloudflare-pages"),
];
};
44 changes: 44 additions & 0 deletions packages/remix-cloudflare-workers/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const path = require("path");
const babel = require("@rollup/plugin-babel").default;
const nodeResolve = require("@rollup/plugin-node-resolve").default;

const {
copyToPlaygrounds,
createBanner,
getAdapterConfig,
getOutputDir,
isBareModuleId,
} = require("../../rollup.utils");
const { name: packageName, version } = require("./package.json");

/** @returns {import("rollup").RollupOptions[]} */
module.exports = function rollup() {
let sourceDir = "packages/remix-cloudflare-workers";
let outputDir = getOutputDir(packageName);
let outputDist = path.join(outputDir, "dist");

return [
{
external(id) {
return isBareModuleId(id);
},
input: `${sourceDir}/index.ts`,
output: {
banner: createBanner("@remix-run/cloudflare-workers", version),
dir: `${outputDist}/esm`,
format: "esm",
preserveModules: true,
},
plugins: [
babel({
babelHelpers: "bundled",
exclude: /node_modules/,
extensions: [".ts", ".tsx"],
}),
nodeResolve({ extensions: [".ts", ".tsx"] }),
copyToPlaygrounds(),
],
},
getAdapterConfig("cloudflare-workers"),
];
};
53 changes: 53 additions & 0 deletions packages/remix-cloudflare/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const path = require("path");
const babel = require("@rollup/plugin-babel").default;
const nodeResolve = require("@rollup/plugin-node-resolve").default;
const copy = require("rollup-plugin-copy");

const {
getOutputDir,
copyToPlaygrounds,
magicExportsPlugin,
isBareModuleId,
createBanner,
} = require("../../rollup.utils");
const { name: packageName, version } = require("./package.json");

/** @returns {import("rollup").RollupOptions[]} */
module.exports = function rollup() {
let sourceDir = "packages/remix-cloudflare";
let outputDir = getOutputDir(packageName);
let outputDist = path.join(outputDir, "dist");

return [
{
external(id) {
return isBareModuleId(id);
},
input: `${sourceDir}/index.ts`,
output: {
banner: createBanner(packageName, version),
dir: outputDist,
format: "cjs",
preserveModules: true,
exports: "named",
},
plugins: [
babel({
babelHelpers: "bundled",
exclude: /node_modules/,
extensions: [".ts", ".tsx"],
}),
nodeResolve({ extensions: [".ts", ".tsx"] }),
copy({
targets: [
{ src: "LICENSE.md", dest: [outputDir, sourceDir] },
{ src: `${sourceDir}/package.json`, dest: outputDir },
{ src: `${sourceDir}/README.md`, dest: outputDir },
],
}),
magicExportsPlugin({ packageName, version }),
copyToPlaygrounds(),
],
},
];
};
27 changes: 27 additions & 0 deletions packages/remix-deno/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// deno-lint-ignore-file
const copy = require("rollup-plugin-copy");

const { getOutputDir, copyToPlaygrounds } = require("../../rollup.utils");

/** @returns {import("rollup").RollupOptions[]} */
module.exports = function rollup() {
let sourceDir = "packages/remix-deno";
let outputDir = getOutputDir("@remix-run/deno");

return [
{
input: `${sourceDir}/.empty.js`,
plugins: [
copy({
targets: [
{ src: "LICENSE.md", dest: [outputDir, sourceDir] },
{ src: `${sourceDir}/**/*`, dest: outputDir },
{ src: `!${sourceDir}/rollup.config.js`, dest: outputDir },
],
gitignore: true,
}),
copyToPlaygrounds(),
],
},
];
};

0 comments on commit d74933f

Please sign in to comment.