From 551c925cf1cdcf7abb8917cddab3c305494b3167 Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Thu, 4 Aug 2022 14:26:41 -0700 Subject: [PATCH 1/4] feat(remix-dev): add suppport for `.mjs` and `.cjs` configs (#3675) --- .changeset/afraid-peaches-accept.md | 5 +++++ packages/remix-dev/config.ts | 32 +++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 .changeset/afraid-peaches-accept.md diff --git a/.changeset/afraid-peaches-accept.md b/.changeset/afraid-peaches-accept.md new file mode 100644 index 00000000000..8774b45b891 --- /dev/null +++ b/.changeset/afraid-peaches-accept.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": patch +--- + +Add support for .mjs and .cjs remix.config files. diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 72927be1a5f..0ac1ce51893 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -287,15 +287,18 @@ export async function readConfig( } let rootDirectory = path.resolve(remixRoot); - let configFile = path.resolve(rootDirectory, "remix.config.js"); - - let appConfig: AppConfig; - try { - appConfig = require(configFile); - } catch (error) { - throw new Error( - `Error loading Remix config in ${configFile}\n${String(error)}` - ); + let configFile = findConfig(rootDirectory, "remix.config"); + + let appConfig: AppConfig = {}; + if (configFile) { + try { + let appConfigModule = await import(configFile); + appConfig = appConfigModule?.default || appConfig; + } catch (error) { + throw new Error( + `Error loading Remix config at ${configFile}\n${String(error)}` + ); + } } let customServerEntryPoint = appConfig.server; @@ -475,3 +478,14 @@ function findEntry(dir: string, basename: string): string | undefined { return undefined; } + +const configExts = [".js", ".cjs", ".mjs"]; + +function findConfig(dir: string, basename: string): string | undefined { + for (let ext of configExts) { + let file = path.resolve(dir, basename + ext); + if (fse.existsSync(file)) return file; + } + + return undefined; +} From 2c93fbfa2021b617afab8addc53e23c3be4986b9 Mon Sep 17 00:00:00 2001 From: Julio Lemos Date: Thu, 4 Aug 2022 18:39:26 -0300 Subject: [PATCH 2/4] chore(remix-dev/cli): fix broken stacks link (#3874) --- packages/remix-dev/cli/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/remix-dev/cli/run.ts b/packages/remix-dev/cli/run.ts index fac58a39778..fb30fe073bc 100644 --- a/packages/remix-dev/cli/run.ts +++ b/packages/remix-dev/cli/run.ts @@ -332,7 +332,7 @@ export async function run(argv: string[] = process.argv.slice(2)) { }, message: "Which Stack do you want? ", loop: false, - suffix: "(Learn more about these stacks: https://remix.run/stacks)", + suffix: "(Learn more about these stacks: 'https://remix.run/stacks')", choices: [ { name: "Blues", From 9e66a5cc0c7ad7297a542cd6d21a05e5fc758be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 4 Aug 2022 23:40:40 +0200 Subject: [PATCH 3/4] chore(examples/blog-tutorial): revert update of `@testing-library/react` dependency (#3924) --- examples/blog-tutorial/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/blog-tutorial/package.json b/examples/blog-tutorial/package.json index bc1787f31df..c970016f2c5 100644 --- a/examples/blog-tutorial/package.json +++ b/examples/blog-tutorial/package.json @@ -46,7 +46,7 @@ "@testing-library/cypress": "^8.0.2", "@testing-library/dom": "^8.13.0", "@testing-library/jest-dom": "^5.16.4", - "@testing-library/react": "^13.3.0", + "@testing-library/react": "^12.1.5", "@testing-library/user-event": "^13.5.0", "@types/eslint": "^8.4.1", "@types/marked": "^4.0.3", From 845c6c3114983f67e940e369671c91b39fcf6e60 Mon Sep 17 00:00:00 2001 From: Remix Run Bot Date: Thu, 4 Aug 2022 21:42:29 +0000 Subject: [PATCH 4/4] chore: format --- packages/remix-dev/cli/run.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/remix-dev/cli/run.ts b/packages/remix-dev/cli/run.ts index fb30fe073bc..868d4071a69 100644 --- a/packages/remix-dev/cli/run.ts +++ b/packages/remix-dev/cli/run.ts @@ -332,7 +332,8 @@ export async function run(argv: string[] = process.argv.slice(2)) { }, message: "Which Stack do you want? ", loop: false, - suffix: "(Learn more about these stacks: 'https://remix.run/stacks')", + suffix: + "(Learn more about these stacks: 'https://remix.run/stacks')", choices: [ { name: "Blues",