Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: default to serverModuleFormat esm #6949

Merged
merged 25 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b037937
feat!: default to serverModuleFormat esm
jacob-ebey Jul 24, 2023
425262a
feat: move integration tests to ESM
jacob-ebey Jul 25, 2023
069dc26
update config snapshot test
jacob-ebey Jul 25, 2023
75f4eaa
attempt to fix module resolution for tsc
jacob-ebey Jul 25, 2023
8770ac7
force module detection for node project
jacob-ebey Jul 25, 2023
be621cf
change to node 18
jacob-ebey Jul 25, 2023
04f9d08
update nvm version again
jacob-ebey Jul 26, 2023
e08553c
revert moduleDetection
jacob-ebey Jul 26, 2023
5ccc5d5
Merge branch 'dev' of https://github.com/remix-run/remix into v2_esm
jacob-ebey Aug 2, 2023
50972a2
Merge branch 'dev' of https://github.com/remix-run/remix into v2_esm
jacob-ebey Aug 2, 2023
bae0b63
use bundler module resolution
jacob-ebey Aug 2, 2023
7a9bbda
fix lint issues
jacob-ebey Aug 2, 2023
e1f9fce
update test
jacob-ebey Aug 2, 2023
e23a045
resolve path for windows CI
jacob-ebey Aug 8, 2023
4f87808
Merge branch 'dev' of https://github.com/remix-run/remix into v2_esm
jacob-ebey Aug 8, 2023
ae19a27
fix postcss
markdalgleish Aug 9, 2023
f04f071
Merge branch 'dev' of https://github.com/remix-run/remix into v2_esm
jacob-ebey Aug 9, 2023
50ac5b5
update test files
jacob-ebey Aug 9, 2023
9882d99
Merge branch 'dev' of https://github.com/remix-run/remix into v2_esm
jacob-ebey Aug 9, 2023
d8f5d07
update hmr postcss config
jacob-ebey Aug 9, 2023
774ee6b
update create-fixture path resolution
jacob-ebey Aug 9, 2023
6c84965
Merge branch 'dev' of https://github.com/remix-run/remix into v2_esm
jacob-ebey Aug 9, 2023
3ea17d5
fix: path resolution updates because windows
jacob-ebey Aug 9, 2023
21ffd26
fix: path resolution updates because windows
jacob-ebey Aug 9, 2023
fd1f59e
Merge branch 'dev' of https://github.com/remix-run/remix into v2_esm
jacob-ebey Aug 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/v2-default-to-esm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@remix-run/dev": major
"@remix-run/serve": major
---

Default to serverModuleFormat esm, and update remix-serve to use dynamic import to support esm and cjs build outputs.
2 changes: 1 addition & 1 deletion docs/file-conventions/remix-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The URL prefix of the browser build with a trailing slash. Defaults to

## postcss

Whether to process CSS using [PostCSS][postcss] if `postcss.config.js` is present. Defaults to `true`.
Whether to process CSS using [PostCSS][postcss] if a PostCSS config file is present. Defaults to `true`.

## routes

Expand Down
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 @@ -481,7 +481,7 @@ If you are using TypeScript, you likely already have a `tsconfig.json` in your p
"esModuleInterop": true,
"jsx": "react-jsx",
"resolveJsonModule": true,
"moduleResolution": "node",
"moduleResolution": "Bundler",
"baseUrl": ".",
"noEmit": true,
"paths": {
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/styling.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,19 +489,19 @@ For example, to use [Autoprefixer][autoprefixer], first install the PostCSS plug
npm install -D autoprefixer
```

Then add `postcss.config.js` in the Remix root referencing the plugin.
Then add a PostCSS config file in the Remix root referencing the plugin.

```js filename=postcss.config.js
```js filename=postcss.config.cjs
module.exports = {
plugins: {
autoprefixer: {},
},
};
```

If you're using [Vanilla Extract][vanilla-extract-2], since it's already playing the role of CSS preprocessor, you may want to apply a different set of PostCSS plugins relative to other styles. To support this, you can export a function from `postcss.config.js` which is given a context object that lets you know when Remix is processing a Vanilla Extract file.
If you're using [Vanilla Extract][vanilla-extract-2], since it's already playing the role of CSS preprocessor, you may want to apply a different set of PostCSS plugins relative to other styles. To support this, you can export a function from your PostCSS config file which is given a context object that lets you know when Remix is processing a Vanilla Extract file.

```js filename=postcss.config.js
```js filename=postcss.config.cjs
module.exports = (ctx) => {
return ctx.remix?.vanillaExtract
? {
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Remix has TypeScript type definitions built-in as well. The starter templates cr
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
Expand Down
6 changes: 3 additions & 3 deletions integration/abort-signal-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test } from "@playwright/test";

import { PlaywrightFixture } from "./helpers/playwright-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";

let fixture: Fixture;
let appFixture: AppFixture;
Expand Down
6 changes: 3 additions & 3 deletions integration/action-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from "@playwright/test";

import { createFixture, createAppFixture, js } from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture, selectHtml } from "./helpers/playwright-fixture";
import { createFixture, createAppFixture, js } from "./helpers/create-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture, selectHtml } from "./helpers/playwright-fixture.js";

test.describe("actions", () => {
let fixture: Fixture;
Expand Down
6 changes: 3 additions & 3 deletions integration/browser-entry-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from "@playwright/test";

import type { AppFixture, Fixture } from "./helpers/create-fixture";
import { createFixture, js, createAppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture";
import type { AppFixture, Fixture } from "./helpers/create-fixture.js";
import { createFixture, js, createAppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";

let fixture: Fixture;
let appFixture: AppFixture;
Expand Down
6 changes: 3 additions & 3 deletions integration/bug-report-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from "@playwright/test";

import { PlaywrightFixture } from "./helpers/playwright-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";

let fixture: Fixture;
let appFixture: AppFixture;
Expand Down
6 changes: 3 additions & 3 deletions integration/catch-boundary-data-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from "@playwright/test";

import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";

let fixture: Fixture;
let appFixture: AppFixture;
Expand Down
6 changes: 3 additions & 3 deletions integration/catch-boundary-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from "@playwright/test";

import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";

test.describe("ErrorBoundary (thrown responses)", () => {
let fixture: Fixture;
Expand Down
3 changes: 2 additions & 1 deletion integration/cf-compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "node:path";
import shell from "shelljs";
import glob from "glob";

import { createFixtureProject, js, json } from "./helpers/create-fixture";
import { createFixtureProject, js, json } from "./helpers/create-fixture.js";

const searchFiles = async (pattern: string | RegExp, files: string[]) => {
let result = shell.grep("-l", pattern, files);
Expand Down Expand Up @@ -36,6 +36,7 @@ test.describe("cloudflare compiler", () => {
private: true,
sideEffects: false,
main: "build/index.js",
type: "module",
dependencies: {
"@remix-run/cloudflare": "0.0.0-local-version",
"@remix-run/cloudflare-workers": "0.0.0-local-version",
Expand Down
2 changes: 1 addition & 1 deletion integration/compiler-mjs-output-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test";
import * as fs from "node:fs";
import * as path from "node:path";

import { createFixtureProject, js } from "./helpers/create-fixture";
import { createFixtureProject, js } from "./helpers/create-fixture.js";

let projectDir: string;

Expand Down
23 changes: 15 additions & 8 deletions integration/compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
json,
createFixtureProject,
css,
} from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture";
} from "./helpers/create-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";

test.describe("compiler", () => {
let fixture: Fixture;
Expand All @@ -25,8 +25,11 @@ test.describe("compiler", () => {
// We need a custom config file here to test usage of `getDependenciesToBundle`
// since this can't be serialized from the fixture object.
"remix.config.js": js`
let { getDependenciesToBundle } = require("@remix-run/dev");
module.exports = {
import { getDependenciesToBundle } from "@remix-run/dev";
export default {
future: {
v2_routeConvention: true,
},
serverDependenciesToBundle: [
"esm-only-pkg",
"esm-only-single-export",
Expand Down Expand Up @@ -94,8 +97,8 @@ test.describe("compiler", () => {
return <div id="esm-only-single-export">{esmOnlyPkg}</div>;
}
`,
"app/routes/package-with-submodule.tsx": js`
import { submodule } from "@org/package/sub-package";
"app/routes/package-with-submodule.jsx": js`
import { submodule } from "@org/package/sub-package/index.js";

export default function PackageWithSubModule() {
return <div id="package-with-submodule">{submodule()}</div>;
Expand Down Expand Up @@ -146,7 +149,9 @@ test.describe("compiler", () => {
version: "1.0.0",
}),
"node_modules/@org/package/sub-package/package.json": json({
module: "./esm/index.js",
module: "./index.js",
exports: "./index.js",
main: "./index.js",
sideEffects: false,
}),
"node_modules/@org/package/sub-package/index.js": js`
Expand All @@ -160,6 +165,8 @@ test.describe("compiler", () => {
"node_modules/@org/package/sub-package/esm/package.json": json({
type: "module",
sideEffects: false,
exports: "./esm/index.js",
main: "./esm/index.js",
}),
"node_modules/@org/package/sub-package/esm/index.js": js`
export { default as submodule } from "./submodule.js";
Expand Down
6 changes: 3 additions & 3 deletions integration/css-modules-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { test, expect } from "@playwright/test";
import globby from "globby";
import fse from "fs-extra";

import { PlaywrightFixture } from "./helpers/playwright-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import {
createAppFixture,
createFixture,
css,
js,
} from "./helpers/create-fixture";
} from "./helpers/create-fixture.js";

const TEST_PADDING_VALUE = "20px";

Expand Down
13 changes: 8 additions & 5 deletions integration/css-side-effect-imports-test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { test, expect } from "@playwright/test";

import { PlaywrightFixture } from "./helpers/playwright-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import {
createAppFixture,
createFixture,
css,
js,
json,
} from "./helpers/create-fixture";
} from "./helpers/create-fixture.js";

const TEST_PADDING_VALUE = "20px";

Expand All @@ -19,7 +19,7 @@ test.describe("CSS side-effect imports", () => {
test.beforeAll(async () => {
fixture = await createFixture({
config: {
serverDependenciesToBundle: [/@test-package/],
serverDependenciesToBundle: ["react", /@test-package/],
},
files: {
"app/root.tsx": js`
Expand Down Expand Up @@ -287,7 +287,10 @@ test.describe("CSS side-effect imports", () => {
);
};
`,
"app/routes/commonjs-package-test.tsx": js`
"node_modules/@test-package/commonjs/package.json": json({
main: "./index.js",
}),
"app/routes/commonjs-package-test.jsx": js`
import { Test } from "@test-package/commonjs";
export default function() {
return <Test />;
Expand Down
6 changes: 3 additions & 3 deletions integration/custom-entry-server-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, test } from "@playwright/test";

import { PlaywrightFixture } from "./helpers/playwright-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";

let fixture: Fixture;
let appFixture: AppFixture;
Expand Down
6 changes: 3 additions & 3 deletions integration/defer-loader-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from "@playwright/test";

import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";

let fixture: Fixture;
let appFixture: AppFixture;
Expand Down
6 changes: 3 additions & 3 deletions integration/defer-test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { test, expect } from "@playwright/test";
import type { ConsoleMessage, Page } from "@playwright/test";

import { PlaywrightFixture } from "./helpers/playwright-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";

const ROOT_ID = "ROOT_ID";
const INDEX_ID = "INDEX_ID";
Expand Down
5 changes: 3 additions & 2 deletions integration/deno-compiler-test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { test, expect } from "@playwright/test";
import * as fse from "fs-extra";
import fse from "fs-extra";
import path from "node:path";
import shell from "shelljs";
import glob from "glob";

import { createFixtureProject, js, json } from "./helpers/create-fixture";
import { createFixtureProject, js, json } from "./helpers/create-fixture.js";

let projectDir: string;

Expand Down Expand Up @@ -39,6 +39,7 @@ test.beforeAll(async () => {
"package.json": json({
private: true,
sideEffects: false,
type: "module",
dependencies: {
"@remix-run/deno": "0.0.0-local-version",
"@remix-run/react": "0.0.0-local-version",
Expand Down
6 changes: 3 additions & 3 deletions integration/deterministic-build-output-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import globby from "globby";
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";
import type { FixtureInit } from "./helpers/create-fixture.js";
import { createFixtureProject, js, css } from "./helpers/create-fixture.js";

test("builds deterministically under different paths", async () => {
// This test validates various flavors of remix virtual modules to ensure
Expand All @@ -28,7 +28,7 @@ test("builds deterministically under different paths", async () => {
let init: FixtureInit = {
files: {
"postcss.config.js": js`
module.exports = {
export default {
plugins: {
"postcss-import": {},
},
Expand Down
8 changes: 4 additions & 4 deletions integration/error-boundary-test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { test, expect } from "@playwright/test";
import { ServerMode } from "@remix-run/server-runtime/mode";

import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture";
import { ServerMode } from "../build/node_modules/@remix-run/server-runtime/dist/mode.js";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";

test.describe("ErrorBoundary", () => {
let fixture: Fixture;
Expand Down
8 changes: 4 additions & 4 deletions integration/error-boundary-v2-test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Page } from "@playwright/test";
import { test, expect } from "@playwright/test";
import { ServerMode } from "@remix-run/server-runtime/mode";

import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { PlaywrightFixture } from "./helpers/playwright-fixture";
import { ServerMode } from "../build/node_modules/@remix-run/server-runtime/dist/mode.js";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";

test.describe("ErrorBoundary", () => {
let fixture: Fixture;
Expand Down
4 changes: 2 additions & 2 deletions integration/error-data-request-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";

import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture.js";
import type { Fixture, AppFixture } from "./helpers/create-fixture.js";

test.describe("ErrorBoundary", () => {
let fixture: Fixture;
Expand Down
Loading