@@ -14,14 +14,13 @@ export interface PluginOptions {
1414 forPrerender ?: boolean
1515}
1616
17- /**
18- * When running from the CLI: Babel-plugin-module-resolver will convert:
19- * - For dev/build/prerender (forJest == false):
20- 'src/pages/ExamplePage' -> './pages/ExamplePage'
21- * - For test (forJest == true):
22- 'src/pages/ExamplePage' -> '/Users/blah/pathToProject/web/src/pages/ExamplePage'
23- */
24- export const getPathRelativeToSrc = ( maybeAbsolutePath : string ) => {
17+ // When running from the CLI: Babel-plugin-module-resolver will convert:
18+ // - For dev/build/prerender (forJest == false):
19+ // 'src/pages/ExamplePage' -> './pages/ExamplePage'
20+ // - For test (forJest == true):
21+ // 'src/pages/ExamplePage' -> '/Users/blah/pathToProject/web/src/pages/ExamplePage'
22+
23+ const getPathRelativeToSrc = ( maybeAbsolutePath : string ) => {
2524 // If the path is already relative
2625 if ( ! path . isAbsolute ( maybeAbsolutePath ) ) {
2726 return maybeAbsolutePath
@@ -30,7 +29,7 @@ export const getPathRelativeToSrc = (maybeAbsolutePath: string) => {
3029 return `./${ path . relative ( getPaths ( ) . web . src , maybeAbsolutePath ) } `
3130}
3231
33- export const withRelativeImports = ( page : PagesDependency ) => {
32+ const withRelativeImports = ( page : PagesDependency ) => {
3433 return {
3534 ...page ,
3635 relativeImport : ensurePosixPath ( getPathRelativeToSrc ( page . importPath ) ) ,
@@ -44,9 +43,10 @@ export default function (
4443 // @NOTE : This var gets mutated inside the visitors
4544 let pages = processPagesDir ( ) . map ( withRelativeImports )
4645
47- // Currently processPagesDir() can return duplicate entries when there are multiple files
48- // ending in Page in the individual page directories. This will cause an error upstream.
49- // Here we check for duplicates and throw a more helpful error message.
46+ // Currently processPagesDir() can return duplicate entries when there are
47+ // multiple files ending in Page in the individual page directories. This will
48+ // cause an error upstream. Here we check for duplicates and throw a more
49+ // helpful error message.
5050 const duplicatePageImportNames = new Set < string > ( )
5151 const sortedPageImportNames = pages . map ( ( page ) => page . importName ) . sort ( )
5252 for ( let i = 0 ; i < sortedPageImportNames . length - 1 ; i ++ ) {
0 commit comments