Skip to content

Commit

Permalink
Merge branch 'dev' into logan/bump-esbuild-auto-jsx-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
mcansh committed Aug 8, 2022
2 parents 9483441 + 845c6c3 commit 81ff481
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-peaches-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

Add support for .mjs and .cjs remix.config files.
2 changes: 1 addition & 1 deletion examples/blog-tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/remix-dev/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 23 additions & 9 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

0 comments on commit 81ff481

Please sign in to comment.