@wular/pnext 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli/adapters/vercel.ts +22 -6
package/package.json
CHANGED
|
@@ -348,7 +348,7 @@ async function writeServerFunction(
|
|
|
348
348
|
// Bun does honor tsconfig paths for bare imports, so map the aliased specifiers to their shims in
|
|
349
349
|
// every shipped tsconfig.
|
|
350
350
|
await log.step('inject compat tsconfig paths', () =>
|
|
351
|
-
injectCompatPaths(config, functionPath, replicaPathFor),
|
|
351
|
+
injectCompatPaths(config, functionPath, pnextRoot, replicaPathFor),
|
|
352
352
|
)
|
|
353
353
|
|
|
354
354
|
const startEntry = toPosixPath(path.join(pnextTargetRel, 'src/cli/start.ts'))
|
|
@@ -731,13 +731,31 @@ function isInsideDir(root: string, file: string) {
|
|
|
731
731
|
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative))
|
|
732
732
|
}
|
|
733
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Whether a compat alias resolves to framework source (react, next/*) rather than to a real package.
|
|
736
|
+
* Containment, not a `node_modules` substring: an installed framework lives under node_modules
|
|
737
|
+
* itself, and a substring test there classifies every next/* shim as a package to ship.
|
|
738
|
+
* @internal Exported for tests.
|
|
739
|
+
*/
|
|
740
|
+
export function isFrameworkOwnedAliasTarget(frameworkRoot: string, target: string) {
|
|
741
|
+
if (!path.isAbsolute(target) || !isInsideDir(frameworkRoot, target)) return false
|
|
742
|
+
// A nested store under the framework root is still a real package.
|
|
743
|
+
return !path.relative(frameworkRoot, target).split(path.sep).includes('node_modules')
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function frameworkOwnedAliases(config: ResolvedConfig, frameworkRoot: string) {
|
|
747
|
+
return Object.entries(getImportAliasExtensions().aliases(config, 'server')).filter(([, target]) =>
|
|
748
|
+
isFrameworkOwnedAliasTarget(frameworkRoot, target),
|
|
749
|
+
)
|
|
750
|
+
}
|
|
751
|
+
|
|
734
752
|
async function injectCompatPaths(
|
|
735
753
|
config: ResolvedConfig,
|
|
736
754
|
functionPath: string,
|
|
755
|
+
frameworkRoot: string,
|
|
737
756
|
replicaPathFor: (file: string) => string | undefined,
|
|
738
757
|
) {
|
|
739
|
-
const aliasTargets =
|
|
740
|
-
.filter(([, target]) => path.isAbsolute(target) && !target.includes('node_modules'))
|
|
758
|
+
const aliasTargets = frameworkOwnedAliases(config, frameworkRoot)
|
|
741
759
|
.map(([specifier, target]) => [specifier, replicaPathFor(target)] as const)
|
|
742
760
|
.filter((entry): entry is readonly [string, string] => Boolean(entry[1]))
|
|
743
761
|
if (aliasTargets.length === 0) return
|
|
@@ -882,9 +900,7 @@ async function traceNodeModulesClosure(
|
|
|
882
900
|
// them would drag in the full next/react trees. Aliases that point into
|
|
883
901
|
// node_modules (the pinned preact family) still need their packages.
|
|
884
902
|
const frameworkAliasedSpecifiers = new Set(
|
|
885
|
-
|
|
886
|
-
.filter(([, target]) => path.isAbsolute(target) && !target.includes('node_modules'))
|
|
887
|
-
.map(([specifier]) => specifier),
|
|
903
|
+
frameworkOwnedAliases(config, path.resolve(framework.root)).map(([specifier]) => specifier),
|
|
888
904
|
)
|
|
889
905
|
await log.step('trace runtime imports', async () => {
|
|
890
906
|
// Only code Bun imports raw at request time needs real node_modules: route handlers, the proxy,
|