File tree Expand file tree Collapse file tree 4 files changed +13
-9
lines changed
Expand file tree Collapse file tree 4 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,8 @@ export default class EdgeBundler extends WebpackBundler {
122122 concatenateModules : false ,
123123 mangleExports : false ,
124124 moduleIds : 'named' ,
125+ // Disable code splitting - Fastly runtime doesn't support importScripts
126+ splitChunks : false ,
125127 } ,
126128 plugins : [ ] ,
127129 } ;
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ export function createFastlyLogger(context) {
6363
6464 // Initialize Fastly logger module asynchronously
6565 // eslint-disable-next-line import/no-unresolved
66- loggerPromise = import ( 'fastly:logger' ) . then ( ( module ) => {
66+ loggerPromise = import ( /* webpackIgnore: true */ 'fastly:logger' ) . then ( ( module ) => {
6767 loggerModule = module ;
6868 loggersReady = true ;
6969 loggerPromise = null ;
Original file line number Diff line number Diff line change 1111 */
1212/* eslint-env serviceworker */
1313
14+ // Static imports to avoid code splitting (Fastly runtime doesn't support importScripts)
15+ import { handleRequest as handleCloudflareRequest } from './cloudflare-adapter.js' ;
16+ import { handleRequest as handleFastlyRequest } from './fastly-adapter.js' ;
17+
1418// Platform detection based on request properties and runtime-specific modules
1519let detectedPlatform = null ;
1620
@@ -29,7 +33,7 @@ async function detectPlatform(request) {
2933 // Try Fastly by checking for fastly:env module
3034 try {
3135 /* eslint-disable-next-line import/no-unresolved */
32- await import ( 'fastly:env' ) ;
36+ await import ( /* webpackIgnore: true */ 'fastly:env' ) ;
3337 detectedPlatform = 'fastly' ;
3438 // eslint-disable-next-line no-console
3539 console . log ( 'detected fastly environment' ) ;
@@ -45,13 +49,11 @@ async function getHandler(request) {
4549 const platform = await detectPlatform ( request ) ;
4650
4751 if ( platform === 'cloudflare' ) {
48- const { handleRequest } = await import ( './cloudflare-adapter.js' ) ;
49- return handleRequest ;
52+ return handleCloudflareRequest ;
5053 }
5154
5255 if ( platform === 'fastly' ) {
53- const { handleRequest } = await import ( './fastly-adapter.js' ) ;
54- return handleRequest ;
56+ return handleFastlyRequest ;
5557 }
5658
5759 return null ;
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ let loggerModule = null;
2626export async function getFastlyEnv ( ) {
2727 if ( ! envModule ) {
2828 /* eslint-disable-next-line import/no-unresolved */
29- envModule = await import ( 'fastly:env' ) ;
29+ envModule = await import ( /* webpackIgnore: true */ 'fastly:env' ) ;
3030 }
3131 return envModule ;
3232}
@@ -41,7 +41,7 @@ export async function getSecretStore() {
4141 }
4242 try {
4343 /* eslint-disable-next-line import/no-unresolved */
44- secretStoreModule = await import ( 'fastly:secret-store' ) ;
44+ secretStoreModule = await import ( /* webpackIgnore: true */ 'fastly:secret-store' ) ;
4545 return secretStoreModule . SecretStore ;
4646 } catch {
4747 return null ;
@@ -58,7 +58,7 @@ export async function getLogger() {
5858 }
5959 try {
6060 /* eslint-disable-next-line import/no-unresolved */
61- loggerModule = await import ( 'fastly:logger' ) ;
61+ loggerModule = await import ( /* webpackIgnore: true */ 'fastly:logger' ) ;
6262 return loggerModule . Logger ;
6363 } catch {
6464 return null ;
You can’t perform that action at this time.
0 commit comments