Skip to content

Commit

Permalink
ref(nextjs): Use bundling instead of proxying to wrap pages and API r…
Browse files Browse the repository at this point in the history
…outes (#6685)
  • Loading branch information
lforst authored Jan 10, 2023
1 parent 5938288 commit f140888
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 227 deletions.
3 changes: 1 addition & 2 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"access": "public"
},
"dependencies": {
"@rollup/plugin-sucrase": "4.0.4",
"@rollup/plugin-virtual": "3.0.0",
"@rollup/plugin-commonjs": "24.0.0",
"@sentry/core": "7.30.0",
"@sentry/integrations": "7.30.0",
"@sentry/node": "7.30.0",
Expand Down
11 changes: 3 additions & 8 deletions packages/nextjs/rollup.npm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ export default [
),
...makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: [
'src/config/templates/pageProxyLoaderTemplate.ts',
'src/config/templates/apiProxyLoaderTemplate.ts',
],
entrypoints: ['src/config/templates/pageWrapperTemplate.ts', 'src/config/templates/apiWrapperTemplate.ts'],

packageSpecificConfig: {
output: {
Expand All @@ -32,15 +29,13 @@ export default [
// make it so Rollup calms down about the fact that we're combining default and named exports
exports: 'named',
},
external: ['@sentry/nextjs', '__RESOURCE_PATH__'],
external: ['@sentry/nextjs', '__SENTRY_WRAPPING_TARGET__'],
},
}),
),
...makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/config/loaders/index.ts'],
// Needed in order to successfully import sucrase
esModuleInterop: true,

packageSpecificConfig: {
output: {
Expand All @@ -50,7 +45,7 @@ export default [
// make it so Rollup calms down about the fact that we're combining default and named exports
exports: 'named',
},
external: ['@rollup/plugin-sucrase', 'rollup'],
external: ['@rollup/plugin-commonjs', 'rollup'],
},
}),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/src/config/loaders/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { default as valueInjectionLoader } from './valueInjectionLoader';
export { default as prefixLoader } from './prefixLoader';
export { default as proxyLoader } from './proxyLoader';
export { default as wrappingLoader } from './wrappingLoader';
98 changes: 0 additions & 98 deletions packages/nextjs/src/config/loaders/proxyLoader.ts

This file was deleted.

104 changes: 0 additions & 104 deletions packages/nextjs/src/config/loaders/rollup.ts

This file was deleted.

8 changes: 8 additions & 0 deletions packages/nextjs/src/config/loaders/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type webpack from 'webpack';

export type LoaderThis<Options> = {
/** Path to the file being loaded */
resourcePath: string;
Expand All @@ -7,6 +9,12 @@ export type LoaderThis<Options> = {

// Function to add outside file used by loader to `watch` process
addDependency: (filepath: string) => void;

// Marks a loader as asynchronous
async: webpack.loader.LoaderContext['async'];

// Return errors, code, and sourcemaps from an asynchronous loader
callback: webpack.loader.LoaderContext['callback'];
} & (
| {
// Loader options in Webpack 4
Expand Down
Loading

0 comments on commit f140888

Please sign in to comment.