Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Support declarationMap for @pika/plugin-ts-standard-pkg #64

Open
Jack-Works opened this issue Jun 30, 2019 · 5 comments · May be fixed by #107
Open

Support declarationMap for @pika/plugin-ts-standard-pkg #64

Jack-Works opened this issue Jun 30, 2019 · 5 comments · May be fixed by #107

Comments

@Jack-Works
Copy link
Contributor

Declaration map just like source map can let IDEs jump to the source file (ts) instead of .js file or .d.ts file.

I found in the source code, pika disabled the declaration map. Why?

https://github.com/pikapkg/builders/blob/master/packages/plugin-ts-standard-pkg/src/index.ts#L106

@FredKSchott
Copy link
Owner

I... don't actually know why that was disabled for all builds, maybe TS turns it on by default? Either way, that feels like something that should be configurable by the user. I'll remove that override so that anyone can configure it in their tsconfig instead

@FredKSchott
Copy link
Owner

Fixed in c4aa9e8

@Jack-Works
Copy link
Contributor Author

Uh, I think this fix doesn't work. It does generate dist-types/*.d.ts.map, but after the package published, the declaration maps are broken.

For example, index.d.ts.map

{
    "version": 3,
    "file": "index.d.ts",
    "sourceRoot": "",
    "sources": ["../../src/index.ts"],
    "names": [],
    "mappings": "AAAA;;;;GAIG;AACH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA"
}

After install, it will become /node_modules/package_name/dist-types/index.d.ts.map, but ../../src/index.ts doesn't contain the source file, so IDE cannot jump to the source location

@kripod
Copy link
Contributor

kripod commented Jan 14, 2020

I have the exact same issue. Is is possible to copy the src folder to the distributed package and then point the declaration maps to TypeScript source files in that folder?

@kripod kripod linked a pull request Jan 14, 2020 that will close this issue
@FredKSchott FredKSchott reopened this Jan 15, 2020
@FredKSchott
Copy link
Owner

Ah, that was probably why it was disabled then. Remind me to add a comment next time :) Thanks everyone for debugging and @kripod for creating a quick fix

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants