diff --git a/packages/solidstart/src/config/wrapServerEntryWithDynamicImport.ts b/packages/solidstart/src/config/wrapServerEntryWithDynamicImport.ts index 6d069220e1ae..8f8c7a59f1f4 100644 --- a/packages/solidstart/src/config/wrapServerEntryWithDynamicImport.ts +++ b/packages/solidstart/src/config/wrapServerEntryWithDynamicImport.ts @@ -53,7 +53,7 @@ export function wrapServerEntryWithDynamicImport(config: WrapServerEntryPluginOp return { id: source, moduleSideEffects: true }; } - if (additionalImports && additionalImports.includes(source)) { + if (additionalImports?.includes(source)) { // When importing additional imports like "import-in-the-middle/hook.mjs" in the returned code of the `load()` function below: // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it // By importing "import-in-the-middle/hook.mjs", we can make sure this file is included, as not all node builders are including files imported with `module.register()`. @@ -70,7 +70,7 @@ export function wrapServerEntryWithDynamicImport(config: WrapServerEntryPluginOp const resolution = await this.resolve(source, importer, options); // If it cannot be resolved or is external, just return it so that Rollup can display an error - if (!resolution || (resolution && resolution.external)) return resolution; + if (!resolution || resolution?.external) return resolution; const moduleInfo = await this.load(resolution); @@ -146,23 +146,21 @@ export function extractFunctionReexportQueryParameters(query: string): { wrap: s const wrapMatch = query.match(wrapRegex); const reexportMatch = query.match(reexportRegex); - const wrap = - wrapMatch && wrapMatch[1] - ? wrapMatch[1] - .split(',') - .filter(param => param !== '') - // Sanitize, as code could be injected with another rollup plugin - .map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) - : []; - - const reexport = - reexportMatch && reexportMatch[1] - ? reexportMatch[1] - .split(',') - .filter(param => param !== '' && param !== 'default') - // Sanitize, as code could be injected with another rollup plugin - .map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) - : []; + const wrap = wrapMatch?.[1] + ? wrapMatch[1] + .split(',') + .filter(param => param !== '') + // Sanitize, as code could be injected with another rollup plugin + .map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) + : []; + + const reexport = reexportMatch?.[1] + ? reexportMatch[1] + .split(',') + .filter(param => param !== '' && param !== 'default') + // Sanitize, as code could be injected with another rollup plugin + .map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) + : []; return { wrap, reexport }; }