You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go to tsup.config.ts. Add the sourcemap: true option to the first config.
pnpm install (please use pnpm v7.12).
pnpm build.
See the following error printed by tsup:
SyntaxError: Unexpected token
in JSON at position 1744
at JSON.parse (<anonymous>)
at /msw/node_modules/.pnpm/tsup@6.7.0_4s7jzcjqpdttwnwh3e3glkuq6y/node_modules/tsup/dist/index.js:1959:18
at async Promise.all (index 3)
at async PluginContainer.buildFinished (/msw/node_modules/.pnpm/tsup@6.7.0_4s7jzcjqpdttwnwh3e3glkuq6y/node_modules/tsup/dist/index.js:1912:5)
at async runEsbuild (/msw/node_modules/.pnpm/tsup@6.7.0_4s7jzcjqpdttwnwh3e3glkuq6y/node_modules/tsup/dist/index.js:1763:5)
at async /msw/node_modules/.pnpm/tsup@6.7.0_4s7jzcjqpdttwnwh3e3glkuq6y/node_modules/tsup/dist/index.js:2362:19
at async Promise.all (index 0)
Inspecting the problematic info.map reveals the problem:
{
"version": 3,
"sources": ["../../src/core/index.ts"],
"sourcesContent": ["import { checkGlobals } from './utils/internal/checkGlobals'\n\nexport { SetupApi } from './SetupApi'\n\n/* Request handlers */\nexport { RequestHandler } from './handlers/RequestHandler'\nexport { http } from './http'\nexport { HttpHandler, HttpMethods } from './handlers/HttpHandler'\nexport { graphql } from './graphql'\nexport { GraphQLHandler } from './handlers/GraphQLHandler'\n\n/* Utils */\nexport { matchRequestUrl } from './utils/matching/matchRequestUrl'\nexport * from './utils/handleRequest'\nexport { cleanUrl } from './utils/url/cleanUrl'\n\n/**\n * Type definitions.\n */\n\nexport type { SharedOptions, LifeCycleEventsMap } from './sharedOptions'\n\nexport type {\n ResponseResolver,\n ResponseResolverReturnType,\n AsyncResponseResolverReturnType,\n RequestHandlerOptions,\n DefaultBodyType,\n DefaultRequestMultipartBody,\n JsonBodyType,\n} from './handlers/RequestHandler'\n\nexport type {\n RequestQuery,\n HttpRequestParsedResult,\n} from './handlers/HttpHandler'\n\nexport type {\n GraphQLVariables,\n GraphQLRequestBody,\n GraphQLJsonRequestBody,\n} from './handlers/GraphQLHandler'\n\nexport type { Path, PathParams, Match } from './utils/matching/matchRequestUrl'\nexport type { ParsedGraphQLRequest } from './utils/internal/parseGraphQLRequest'\n\nexport * from './HttpResponse'\nexport * from './delay'\nexport { bypass } from './bypass'\nexport { passthrough } from './passthrough'\n\n// Validate environmental globals before executing any code.\n// This ensures that the library gives user-friendly errors\n// when ran in the environments that require additional polyfills\n// from the end user.\ncheckGlobals()\n.mjs'],
"mappings": "AAAA,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AAGzB,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AACrB,SAAS,aAAa,mBAAmB;AACzC,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAG/B,SAAS,uBAAuB;AAChC,cAAc;AACd,SAAS,gBAAgB;AAgCzB,cAAc;AACd,cAAc;AACd,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAM5B,aAAa;",
"names": []
}
The sourcesContent key contains a string that opens with double quotes " but ends with a single quote ', causing invalid JSON and failing the sourcemap generation.
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
We receive the funding once the issue is completed & confirmed by you.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
kettanaito
changed the title
Incorrect "sourcesContent" when using the "sourcemap" option
Incorrect JSON in "sourcesContent" with the "sourcemap" option
Jan 7, 2024
Found the root cause. I had a custom plugin that was modifying the outputted chunks. Since with sourcemap: true sourcemaps also became outputted chunks, the plugin was modifying them also, resulting in invalid sourcemaps. Not an issue of tsup.
Reproduction steps
tsup: 8.0.1
node: v18.17.0
tsup.config.ts
. Add thesourcemap: true
option to the first config.pnpm install
(please use pnpm v7.12).pnpm build
.See the following error printed by tsup:
Inspecting the problematic
info.map
reveals the problem:The
sourcesContent
key contains a string that opens with double quotes"
but ends with a single quote'
, causing invalid JSON and failing the sourcemap generation.Upvote & Fund
The text was updated successfully, but these errors were encountered: