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(remix-dev): add warning for v2 "cjs"->"esm" defaults #6154

Merged
merged 3 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/cjs-esm-warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

add warning for v2 "cjs"->"esm" serverModuleFormat default change
6 changes: 6 additions & 0 deletions docs/pages/v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,12 @@ module.exports = {
};
```

## `serverModuleFormat`

The default server module output format will be changing from `cjs` to `esm`.

In your `remix.config.js`, you should specify either `serverModuleFormat: "cjs"` to retain existing behavior, or `serverModuleFormat: "esm"`, to opt into the future behavior.

## Dev Server

We are still stabilizing the new dev server that enables HMR, several CSS libraries (CSS Modules, Vanilla Extract, Tailwind, PostCSS) and simplifies integration with various servers.
Expand Down
3 changes: 3 additions & 0 deletions packages/remix-dev/__tests__/create-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
flatRoutesWarning,
formMethodWarning,
metaWarning,
serverModuleFormatWarning,
} from "../config";

beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
Expand Down Expand Up @@ -359,6 +360,8 @@ describe("the create command", () => {
"\n" +
metaWarning +
"\n" +
serverModuleFormatWarning +
"\n" +
flatRoutesWarning +
"\n\n" +
getOptOutOfInstallMessage() +
Expand Down
11 changes: 11 additions & 0 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ export async function readConfig(
let serverEntryPoint = appConfig.server;
let serverMainFields = appConfig.serverMainFields;
let serverMinify = appConfig.serverMinify;

if (!appConfig.serverModuleFormat) {
warnOnce(serverModuleFormatWarning, "serverModuleFormatWarning")
}

let serverModuleFormat = appConfig.serverModuleFormat || "cjs";
let serverPlatform = appConfig.serverPlatform || "node";
if (isCloudflareRuntime) {
Expand Down Expand Up @@ -893,6 +898,12 @@ export let serverBuildTargetWarning =
"For instructions on making this change see " +
"https://remix.run/docs/en/v1.15.0/pages/v2#serverbuildtarget";

export const serverModuleFormatWarning =
"⚠️ REMIX FUTURE CHANGE: The `serverModuleFormat` config default option will be changing in v2 " +
"from `cjs` to `esm`. You can prepare for this change by explicitly specifying `serverModuleFormat: 'cjs'`. " +
"For instructions on making this change see " +
"https://remix.run/docs/en/v1.16.0/pages/v2#servermoduleformat";

export let flatRoutesWarning =
"⚠️ REMIX FUTURE CHANGE: The route file convention is changing in v2. " +
"You can prepare for this change at your convenience with the `v2_routeConvention` future flag. " +
Expand Down