Skip to content

Commit b9dcde5

Browse files
Rename pagesDir -> routesDir
1 parent f63b271 commit b9dcde5

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

examples/demo/wmr.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ export default function () {
33
alias: {
44
'src/*': 'src'
55
},
6-
pagesDir: 'public/pages2'
6+
routesDir: 'public/pages2'
77
};
88
}

packages/wmr/src/cli.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function bool(v) {
1616
// global options
1717
prog
1818
.option('--cwd', 'The working directory - equivalent to "(cd FOO && wmr)"')
19-
.option('--pagesDir', 'Directory for filesystem-based routes(default: <cwd>/pages)')
19+
.option('--routesDir', 'Directory for filesystem-based routes(default: <cwd>/routes)')
2020
// Setting env variables isn't common knowledege for many windows users. Much
2121
// easier to pass a flag to our binary instead.
2222
.option('--debug', 'Print internal debugging messages to the console. Same as setting DEBUG=true');
@@ -30,7 +30,6 @@ prog
3030
.option('--visualize', 'Launch interactive bundle visualizer')
3131
.action(opts => {
3232
opts.minify = opts.minify !== false && !/false|0/.test(opts.minify);
33-
console.log(opts);
3433
run(build(opts));
3534
});
3635

@@ -56,7 +55,6 @@ prog
5655
.option('--profile', 'Generate build statistics')
5756
.option('--reload', 'Switch off hmr and reload on file saves')
5857
.action(opts => {
59-
console.log(opts);
6058
opts.optimize = !/false|0/.test(opts.compress);
6159
opts.compress = bool(opts.compress);
6260
if (/true/.test(process.env.PROFILE || '')) opts.profile = true;

packages/wmr/src/lib/normalize-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function normalizeOptions(options, mode, configWatchFiles = []) {
2828
options.middleware = [];
2929
options.features = { preact: true };
3030
options.alias = options.alias || options.aliases || {};
31-
options.pagesDir = join(options.cwd, options.pagesDir || 'pages');
31+
options.routesDir = join(options.cwd, options.routesDir || 'pages');
3232

3333
// `wmr` / `wmr start` is a development command.
3434
// `wmr build` / `wmr serve` are production commands.

packages/wmr/src/lib/plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function getPlugins(options) {
4646
jsonPlugin({ cwd }),
4747
bundlePlugin({ inline: !production, cwd }),
4848
aliasPlugin({ alias, cwd: root }),
49-
fsRoutesPlugin({ pagesDir: options.pagesDir, cwd, root, publicPath: options.publicPath }),
49+
fsRoutesPlugin({ routesDir: options.routesDir, cwd, root, publicPath: options.publicPath }),
5050
fsRoutesPreactPlugin(),
5151
sucrasePlugin({
5252
typescript: true,

packages/wmr/src/plugins/fs-routes-plugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ async function readRecursive(root, dir = root) {
3838
/**
3939
* Convert JSX to HTM
4040
* @param {object} options
41-
* @param {string} options.pagesDir Controls whether files are processed to transform JSX.
41+
* @param {string} options.routesDir Controls whether files are processed to transform JSX.
4242
* @param {string} options.cwd
4343
* @param {string} options.root
4444
* @param {string} options.publicPath
4545
* @returns {import('wmr').Plugin}
4646
*/
47-
export default function fsRoutesPlugin({ pagesDir, publicPath, root, cwd }) {
47+
export default function fsRoutesPlugin({ routesDir, publicPath, root, cwd }) {
4848
const PUBLIC = 'wmr:fs-routes';
4949
const INTERNAL = '\0wmr:fs-routes';
5050
return {
@@ -57,8 +57,8 @@ export default function fsRoutesPlugin({ pagesDir, publicPath, root, cwd }) {
5757
async load(id) {
5858
if (id !== INTERNAL) return;
5959

60-
const routes = await readRecursive(pagesDir);
61-
const base = toPosix(path.relative(cwd, path.join(root, pagesDir)));
60+
const routes = await readRecursive(routesDir);
61+
const base = toPosix(path.relative(cwd, path.join(root, routesDir)));
6262

6363
const routesStr = routes
6464
.map(route => {

packages/wmr/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ declare module 'wmr' {
3535
host: string;
3636
port: number;
3737
root: string;
38-
pagesDir: string;
38+
routesDir: string;
3939
out: string;
4040
overlayDir: string;
4141
sourcemap: boolean;

0 commit comments

Comments
 (0)