@tanstack/start-plugin-core 1.169.17 → 1.169.19
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/dist/esm/import-protection/analysis.d.ts +5 -5
- package/dist/esm/import-protection/analysis.js +13 -9
- package/dist/esm/import-protection/analysis.js.map +1 -1
- package/dist/esm/import-protection/rewrite.js +5 -3
- package/dist/esm/import-protection/rewrite.js.map +1 -1
- package/dist/esm/import-protection/sourceLocation.d.ts +3 -2
- package/dist/esm/import-protection/sourceLocation.js +1 -0
- package/dist/esm/import-protection/sourceLocation.js.map +1 -1
- package/dist/esm/rsbuild/import-protection.js +9 -6
- package/dist/esm/rsbuild/import-protection.js.map +1 -1
- package/dist/esm/rsbuild/plugin.js +1 -0
- package/dist/esm/rsbuild/plugin.js.map +1 -1
- package/dist/esm/start-compiler/compiler.d.ts +4 -2
- package/dist/esm/start-compiler/compiler.js +8 -4
- package/dist/esm/start-compiler/compiler.js.map +1 -1
- package/dist/esm/vite/import-protection-plugin/plugin.js +4 -3
- package/dist/esm/vite/import-protection-plugin/plugin.js.map +1 -1
- package/package.json +8 -8
- package/src/import-protection/analysis.ts +22 -10
- package/src/import-protection/rewrite.ts +4 -5
- package/src/import-protection/sourceLocation.ts +4 -2
- package/src/rsbuild/import-protection.ts +7 -5
- package/src/rsbuild/plugin.ts +3 -0
- package/src/start-compiler/compiler.ts +13 -3
- package/src/vite/import-protection-plugin/plugin.ts +4 -3
- package/dist/esm/import-protection/ast.d.ts +0 -3
- package/dist/esm/import-protection/ast.js +0 -9
- package/dist/esm/import-protection/ast.js.map +0 -1
- package/src/import-protection/ast.ts +0 -7
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
} from './analysis'
|
|
9
9
|
import { getOrCreate, normalizeFilePath } from './utils'
|
|
10
10
|
import type { ImportAnalysis } from './analysis'
|
|
11
|
-
import type { ParsedAst } from './ast'
|
|
12
11
|
import type { Loc } from './trace'
|
|
12
|
+
import type { ParseAstResult } from '@tanstack/router-utils'
|
|
13
13
|
import type { RawSourceMap } from 'source-map'
|
|
14
14
|
|
|
15
15
|
// Source-map type compatible with both Rollup's SourceMap and source-map's
|
|
@@ -31,12 +31,13 @@ export interface SourceMapLike {
|
|
|
31
31
|
// Transform result provider (replaces ctx.load() which doesn't work in dev)
|
|
32
32
|
export interface TransformResult {
|
|
33
33
|
code: string
|
|
34
|
+
filename?: string
|
|
34
35
|
map: SourceMapLike | undefined
|
|
35
36
|
originalCode: string | undefined
|
|
36
37
|
originalResult?: TransformResult
|
|
37
38
|
/** Precomputed line index for `code` (index → line/col). */
|
|
38
39
|
lineIndex?: LineIndex
|
|
39
|
-
parsedAst?:
|
|
40
|
+
parsedAst?: ParseAstResult
|
|
40
41
|
analysis?: ImportAnalysis
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -335,6 +336,7 @@ export function getOrCreateOriginalTransformResult(
|
|
|
335
336
|
if (!result.originalResult) {
|
|
336
337
|
result.originalResult = {
|
|
337
338
|
code: result.originalCode,
|
|
339
|
+
filename: result.filename,
|
|
338
340
|
map: undefined,
|
|
339
341
|
originalCode: result.originalCode,
|
|
340
342
|
}
|
|
@@ -559,6 +559,7 @@ async function buildTransformResultProvider(opts: {
|
|
|
559
559
|
|
|
560
560
|
const result: TransformResult = {
|
|
561
561
|
code,
|
|
562
|
+
filename: resource ?? file,
|
|
562
563
|
map,
|
|
563
564
|
originalCode,
|
|
564
565
|
lineIndex: buildLineIndex(code),
|
|
@@ -844,7 +845,7 @@ async function getMarkerKindForFile(opts: {
|
|
|
844
845
|
return undefined
|
|
845
846
|
}
|
|
846
847
|
|
|
847
|
-
const imports = getImportSources(code)
|
|
848
|
+
const imports = getImportSources(code, opts.file)
|
|
848
849
|
const hasServerOnly = imports.some((source) =>
|
|
849
850
|
opts.config.markerSpecifiers.serverOnly.has(source),
|
|
850
851
|
)
|
|
@@ -1107,7 +1108,7 @@ export function registerImportProtection(
|
|
|
1107
1108
|
|
|
1108
1109
|
const matchers = getRulesForEnvironment(config, envName)
|
|
1109
1110
|
const relativeFile = getImportProtectionRelativePath(config.root, file)
|
|
1110
|
-
const importSources = getImportSources(ctx.code)
|
|
1111
|
+
const importSources = getImportSources(ctx.code, file)
|
|
1111
1112
|
const transformedImportSources = new Set(importSources)
|
|
1112
1113
|
const transformInputFileSystem = shared.inputFileSystems[envName]
|
|
1113
1114
|
const loadOriginalCodeForTransform: OriginalCodeLoader =
|
|
@@ -1127,12 +1128,13 @@ export function registerImportProtection(
|
|
|
1127
1128
|
)
|
|
1128
1129
|
: undefined
|
|
1129
1130
|
const buildImportSources = originalCode
|
|
1130
|
-
? getImportSources(originalCode)
|
|
1131
|
+
? getImportSources(originalCode, file)
|
|
1131
1132
|
: []
|
|
1132
1133
|
const buildTransformResult: TransformResult | undefined =
|
|
1133
1134
|
config.command === 'build'
|
|
1134
1135
|
? {
|
|
1135
1136
|
code: ctx.code,
|
|
1137
|
+
filename: file,
|
|
1136
1138
|
map: undefined,
|
|
1137
1139
|
originalCode,
|
|
1138
1140
|
lineIndex: buildLineIndex(ctx.code),
|
|
@@ -1191,7 +1193,7 @@ export function registerImportProtection(
|
|
|
1191
1193
|
let exportNames: Array<string> = []
|
|
1192
1194
|
|
|
1193
1195
|
try {
|
|
1194
|
-
exportNames = getNamedExports(ctx.code)
|
|
1196
|
+
exportNames = getNamedExports(ctx.code, file)
|
|
1195
1197
|
} catch {
|
|
1196
1198
|
exportNames = []
|
|
1197
1199
|
}
|
|
@@ -1215,7 +1217,7 @@ export function registerImportProtection(
|
|
|
1215
1217
|
const deniedSpecifierReplacements = new Map<string, string>()
|
|
1216
1218
|
const exportsBySource = (() => {
|
|
1217
1219
|
try {
|
|
1218
|
-
return getMockExportNamesBySource(ctx.code)
|
|
1220
|
+
return getMockExportNamesBySource(ctx.code, file)
|
|
1219
1221
|
} catch {
|
|
1220
1222
|
return new Map<string, Array<string>>()
|
|
1221
1223
|
}
|
package/src/rsbuild/plugin.ts
CHANGED
|
@@ -199,6 +199,9 @@ export function tanStackStartRsbuild(
|
|
|
199
199
|
},
|
|
200
200
|
},
|
|
201
201
|
server: {
|
|
202
|
+
// Rsbuild compression currently treats Node's raw header array
|
|
203
|
+
// writeHead form as an object, which corrupts SSR response headers.
|
|
204
|
+
compress: false,
|
|
202
205
|
// SSR apps render every route on the server — disable HTML
|
|
203
206
|
// fallback so rsbuild doesn't intercept /_serverFn/ URLs.
|
|
204
207
|
htmlFallback: false,
|
|
@@ -863,8 +863,16 @@ export class StartCompiler {
|
|
|
863
863
|
return info
|
|
864
864
|
}
|
|
865
865
|
|
|
866
|
-
public ingestModule({
|
|
867
|
-
|
|
866
|
+
public ingestModule({
|
|
867
|
+
code,
|
|
868
|
+
id,
|
|
869
|
+
parserFilename,
|
|
870
|
+
}: {
|
|
871
|
+
code: string
|
|
872
|
+
id: string
|
|
873
|
+
parserFilename?: string
|
|
874
|
+
}) {
|
|
875
|
+
const ast = parseAst({ code, filename: parserFilename ?? cleanId(id) })
|
|
868
876
|
const info = this.extractModuleInfo(ast, id)
|
|
869
877
|
return { info, ast }
|
|
870
878
|
}
|
|
@@ -974,10 +982,12 @@ export class StartCompiler {
|
|
|
974
982
|
public async compile({
|
|
975
983
|
code,
|
|
976
984
|
id,
|
|
985
|
+
parserFilename,
|
|
977
986
|
detectedKinds,
|
|
978
987
|
}: {
|
|
979
988
|
code: string
|
|
980
989
|
id: string
|
|
990
|
+
parserFilename?: string
|
|
981
991
|
/** Pre-detected kinds present in this file. If not provided, all valid kinds are checked. */
|
|
982
992
|
detectedKinds?: Set<LookupKind>
|
|
983
993
|
}) {
|
|
@@ -1008,7 +1018,7 @@ export class StartCompiler {
|
|
|
1008
1018
|
|
|
1009
1019
|
// Always parse and extract module info upfront.
|
|
1010
1020
|
// This ensures the module is cached for import resolution even if no candidates are found.
|
|
1011
|
-
const { ast } = this.ingestModule({ code, id })
|
|
1021
|
+
const { ast } = this.ingestModule({ code, id, parserFilename })
|
|
1012
1022
|
|
|
1013
1023
|
// Single-pass traversal to:
|
|
1014
1024
|
// 1. Collect candidate paths (only candidates, not all CallExpressions)
|
|
@@ -539,7 +539,7 @@ export function importProtectionPlugin(
|
|
|
539
539
|
return []
|
|
540
540
|
|
|
541
541
|
try {
|
|
542
|
-
parsedBySource = getMockExportNamesBySource(importerCode)
|
|
542
|
+
parsedBySource = getMockExportNamesBySource(importerCode, importerFile)
|
|
543
543
|
|
|
544
544
|
// Also index by resolved physical IDs so later lookups match.
|
|
545
545
|
await recordMockExportsForImporter(
|
|
@@ -1853,7 +1853,7 @@ export function importProtectionPlugin(
|
|
|
1853
1853
|
// Falls back to empty list on non-standard syntax.
|
|
1854
1854
|
let exportNames: Array<string> = []
|
|
1855
1855
|
try {
|
|
1856
|
-
exportNames = getNamedExports(code)
|
|
1856
|
+
exportNames = getNamedExports(code, file)
|
|
1857
1857
|
} catch {
|
|
1858
1858
|
// Parsing may fail on non-standard syntax
|
|
1859
1859
|
}
|
|
@@ -1913,6 +1913,7 @@ export function importProtectionPlugin(
|
|
|
1913
1913
|
|
|
1914
1914
|
const result: TransformResult = {
|
|
1915
1915
|
code,
|
|
1916
|
+
filename: file,
|
|
1916
1917
|
map,
|
|
1917
1918
|
originalCode,
|
|
1918
1919
|
lineIndex,
|
|
@@ -1931,7 +1932,7 @@ export function importProtectionPlugin(
|
|
|
1931
1932
|
// Dev mode: resolve imports, populate graph, detect violations,
|
|
1932
1933
|
// and rewrite denied imports.
|
|
1933
1934
|
const isDevMock = config.effectiveBehavior === 'mock'
|
|
1934
|
-
const importSources = getImportSources(code)
|
|
1935
|
+
const importSources = getImportSources(code, file)
|
|
1935
1936
|
const resolvedChildren = new Set<string>()
|
|
1936
1937
|
const deniedSourceReplacements = new Map<string, string>()
|
|
1937
1938
|
for (const src of importSources) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","names":[],"sources":["../../../src/import-protection/ast.ts"],"sourcesContent":["import { parseAst } from '@tanstack/router-utils'\n\nexport type ParsedAst = ReturnType<typeof parseAst>\n\nexport function parseImportProtectionAst(code: string): ParsedAst {\n return parseAst({ code })\n}\n"],"mappings":";;AAIA,SAAgB,yBAAyB,MAAyB;AAChE,QAAO,SAAS,EAAE,MAAM,CAAC"}
|