Skip to content

Commit 81056c0

Browse files
committed
add template for prepended code
1 parent c7fc025 commit 81056c0

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

packages/nextjs/rollup.npm.config.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js';
22

3-
export default makeNPMConfigVariants(
4-
makeBaseNPMConfig({
5-
// We need to include `instrumentServer.ts` separately because it's only conditionally required, and so rollup
6-
// doesn't automatically include it when calculating the module dependency tree.
7-
entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/utils/instrumentServer.ts'],
8-
// prevent this nextjs code from ending up in our built package (this doesn't happen automatially because the name
9-
// doesn't match an SDK dependency)
10-
packageSpecificConfig: { external: ['next/router'] },
11-
}),
12-
);
3+
export default [
4+
...makeNPMConfigVariants(
5+
makeBaseNPMConfig({
6+
// We need to include `instrumentServer.ts` separately because it's only conditionally required, and so rollup
7+
// doesn't automatically include it when calculating the module dependency tree.
8+
entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/utils/instrumentServer.ts'],
9+
10+
// prevent this internal nextjs code from ending up in our built package (this doesn't happen automatially because
11+
// the name doesn't match an SDK dependency)
12+
packageSpecificConfig: { external: ['next/router'] },
13+
}),
14+
),
15+
...makeNPMConfigVariants(
16+
makeBaseNPMConfig({
17+
entrypoints: ['src/config/prefixLoaderTemplate.ts'],
18+
19+
packageSpecificConfig: {
20+
output: {
21+
// preserve the original file structure (i.e., so that everything is still relative to `src`)
22+
entryFileNames: 'config/[name].js',
23+
24+
// this is going to be add-on code, so it doesn't need the trappings of a full module (and in fact actively
25+
// shouldn't have them, lest they muck with the module to which we're adding it)
26+
sourcemap: false,
27+
esModule: false,
28+
},
29+
},
30+
}),
31+
),
32+
];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
2+
(global as any).__rewriteFramesDistDir__ = '__DIST_DIR__';
3+
4+
// We need this to make this file an ESM module, which TS requires when using `isolatedModules`.
5+
export {};

0 commit comments

Comments
 (0)