|
1 | 1 | /**
|
2 |
| - * This loader auto-wraps a user's page-level data-fetching functions (`getStaticPaths`, `getStaticProps`, and |
3 |
| - * `getServerSideProps`) in order to instrument them for tracing. At a high level, this is done by finding the relevant |
4 |
| - * functions, renaming them so as not to create a name collision, and then creating a new version of each function which |
5 |
| - * is a wrapped version of the original. We do this by parsing the user's code and some template code into ASTs, |
6 |
| - * manipulating them, and then turning them back into strings and appending our template code to the user's (modified) |
7 |
| - * page code. Greater detail and explanations can be found in situ in the functions below and in the helper functions in |
8 |
| - * `ast.ts`. |
| 2 | + * This loader auto-wraps a user's page-level data-fetching functions (`getStaticProps` and `getServerSideProps`) in |
| 3 | + * order to instrument them for tracing. At a high level, this is done by finding the relevant functions, renaming them |
| 4 | + * so as not to create a name collision, and then creating a new version of each function which is a wrapped version of |
| 5 | + * the original. We do this by parsing the user's code and some template code into ASTs, manipulating them, and then |
| 6 | + * turning them back into strings and appending our template code to the user's (modified) page code. Greater detail and |
| 7 | + * explanations can be found in situ in the functions below and in the helper functions in `ast.ts`. |
9 | 8 | *
|
10 | 9 | * For `getInitialProps` we create a virtual proxy-module that re-exports all the exports and default exports of the
|
11 | 10 | * original file and wraps `getInitialProps`. We do this since it allows us to very generically wrap `getInitialProps`
|
@@ -34,7 +33,6 @@ import type { LoaderThis } from './types';
|
34 | 33 | const DATA_FETCHING_FUNCTIONS = {
|
35 | 34 | getServerSideProps: { placeholder: '__ORIG_GSSP__', alias: '' },
|
36 | 35 | getStaticProps: { placeholder: '__ORIG_GSPROPS__', alias: '' },
|
37 |
| - getStaticPaths: { placeholder: '__ORIG_GSPATHS__', alias: '' }, |
38 | 36 | };
|
39 | 37 |
|
40 | 38 | type LoaderOptions = {
|
@@ -102,7 +100,7 @@ function wrapFunctions(userCode: string, templateCode: string, filepath: string)
|
102 | 100 | }
|
103 | 101 |
|
104 | 102 | /**
|
105 |
| - * Wrap `getStaticPaths`, `getStaticProps`, and `getServerSideProps` (if they exist) in the given page code |
| 103 | + * Wrap `getStaticProps` and `getServerSideProps` (if they exist) in the given page code |
106 | 104 | */
|
107 | 105 | export default function wrapDataFetchersLoader(this: LoaderThis<LoaderOptions>, userCode: string): string {
|
108 | 106 | // For now this loader only works for ESM code
|
|
0 commit comments