Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(nextjs): Use bundling instead of proxying to wrap pages and API routes #6685

Merged
merged 12 commits into from
Jan 10, 2023
Merged
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ jobs:
if: needs.job_get_metadata.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
bundle:
- esm
Expand Down
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