Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use inline source maps for declaration file redirects #588

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-pandas-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@preconstruct/cli": patch
---

Use inline source maps for declaration file redirects
32 changes: 7 additions & 25 deletions packages/cli/src/__tests__/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,7 @@ test("typescript", async () => {
鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript.cjs.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "../src/index";
export { default } from "../src/index";
//# sourceMappingURL=typescript.cjs.d.ts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript.cjs.d.ts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"typescript.cjs.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNjcmlwdC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 src/one-more-thing.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
declare var obj: object;
Expand Down Expand Up @@ -359,10 +356,7 @@ test("flow and .d.ts", async () => {
expect(files).toMatchInlineSnapshot(`
鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/pkg.cjs.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "../src/index.js";
//# sourceMappingURL=pkg.cjs.d.ts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/pkg.cjs.d.ts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"pkg.cjs.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGtnLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/pkg.cjs.js.flow 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
// @flow
Expand Down Expand Up @@ -410,7 +404,7 @@ test(".d.ts file with default export", async () => {
鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript.cjs.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "../src/index.js";
export { default } from "../src/index.js";
//# sourceMappingURL=typescript.cjs.d.ts.map
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNjcmlwdC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9

`);
});
Expand Down Expand Up @@ -493,18 +487,12 @@ test("with default", async () => {
鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/dist/pkg-a.cjs.d.mts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "../src/index.js";
export { _default as default } from "./pkg-a.cjs.default.js";
//# sourceMappingURL=pkg-a.cjs.d.mts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/dist/pkg-a.cjs.d.mts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"pkg-a.cjs.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGtnLWEuY2pzLmQubXRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/dist/pkg-a.cjs.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "../src/index";
export { default } from "../src/index";
//# sourceMappingURL=pkg-a.cjs.d.ts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/dist/pkg-a.cjs.d.ts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"pkg-a.cjs.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGtnLWEuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/dist/pkg-a.cjs.default.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export { default as _default } from "../src/index.js"
Expand All @@ -521,18 +509,12 @@ test("with default", async () => {
鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/something/dist/pkg-a-something.cjs.d.mts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "../../src/something.js";
export { _default as default } from "./pkg-a-something.cjs.default.js";
//# sourceMappingURL=pkg-a-something.cjs.d.mts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/something/dist/pkg-a-something.cjs.d.mts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"pkg-a-something.cjs.d.mts","sourceRoot":"","sources":["../../src/something.tsx"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGtnLWEtc29tZXRoaW5nLmNqcy5kLm10cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zb21ldGhpbmcudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/something/dist/pkg-a-something.cjs.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "../../src/something";
export { default } from "../../src/something";
//# sourceMappingURL=pkg-a-something.cjs.d.ts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/something/dist/pkg-a-something.cjs.d.ts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"pkg-a-something.cjs.d.ts","sourceRoot":"","sources":["../../src/something.tsx"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGtnLWEtc29tZXRoaW5nLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NvbWV0aGluZy50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 packages/pkg-a/something/dist/pkg-a-something.cjs.default.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export { default as _default } from "../../src/something.js"
Expand Down
7 changes: 1 addition & 6 deletions packages/cli/src/build/__tests__/__snapshots__/basic.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ exports[`typescript thing: declarations/src/index.d.ts 1`] = `

exports[`typescript thing: weird-typescript-thing.cjs.d.ts 1`] = `
"export * from "./declarations/src/index";
//# sourceMappingURL=weird-typescript-thing.cjs.d.ts.map
"
`;

exports[`typescript thing: weird-typescript-thing.cjs.d.ts.map 1`] = `
"{"version":3,"file":"weird-typescript-thing.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2VpcmQtdHlwZXNjcmlwdC10aGluZy5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
"
`;

Expand Down
7 changes: 1 addition & 6 deletions packages/cli/src/build/__tests__/__snapshots__/other.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,7 @@ export type RootState = ReturnType<typeof rootReducer>;

exports[`typescript with forced dts emit: dist/typescript-force-dts-emit.cjs.d.ts 1`] = `
"export * from "./declarations/src/index";
//# sourceMappingURL=typescript-force-dts-emit.cjs.d.ts.map
"
`;

exports[`typescript with forced dts emit: dist/typescript-force-dts-emit.cjs.d.ts.map 1`] = `
"{"version":3,"file":"typescript-force-dts-emit.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNjcmlwdC1mb3JjZS1kdHMtZW1pdC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
"
`;

Expand Down
15 changes: 3 additions & 12 deletions packages/cli/src/build/__tests__/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ test("typescript declarationMap", async () => {
{"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,OAAiB,CAAC"}
鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript-declarationMap.cjs.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "./declarations/src/index";
//# sourceMappingURL=typescript-declarationMap.cjs.d.ts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript-declarationMap.cjs.d.ts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"typescript-declarationMap.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNjcmlwdC1kZWNsYXJhdGlvbk1hcC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript-declarationMap.cjs.dev.js, dist/typescript-declarationMap.cjs.prod.js 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
'use strict';
Expand Down Expand Up @@ -1114,10 +1111,7 @@ test("typescript declaration emit with json import", async () => {

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/scope-test.cjs.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "./declarations/src/index";
//# sourceMappingURL=scope-test.cjs.d.ts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/scope-test.cjs.d.ts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"scope-test.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NvcGUtdGVzdC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/scope-test.cjs.dev.js, dist/scope-test.cjs.prod.js 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
'use strict';
Expand Down Expand Up @@ -1287,10 +1281,7 @@ test(".d.ts file with default export", async () => {
鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript.cjs.d.ts 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
export * from "./declarations/src/index";
export { default } from "./declarations/src/index";
//# sourceMappingURL=typescript.cjs.d.ts.map

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript.cjs.d.ts.map 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
{"version":3,"file":"typescript.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNjcmlwdC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=

鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆 dist/typescript.cjs.dev.js, dist/typescript.cjs.prod.js 鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆鈳幆
'use strict';
Expand Down