-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expose typings to project code #68
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
95fd068
73d41d6
db9e5f9
842402c
5ec4431
e37a908
b445376
f238058
f2acabe
c4e7fd1
666e59c
61a0fb6
19aeb8f
018ad14
433b16c
ecd741c
4744fd7
8f8f54c
1ea6a0f
49d080e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| .DS_Store | ||
| /node_modules | ||
| /dist | ||
| /assets/client.* | ||
| /assets/client.* | ||
| /client/**/*.d.ts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| /* Generates the typings for client code */ | ||
| "compilerOptions": { | ||
| "resolveJsonModule": true, | ||
| "module": "esnext", | ||
| "moduleResolution": "node", | ||
| "target": "ES6", | ||
| "esModuleInterop": true, | ||
| "emitDeclarationOnly": true, | ||
| "declaration": true, | ||
| "outDir": "." | ||
| }, | ||
| "include": ["../src/client/**/*", "../src/ambient.d.ts"], | ||
| "lib": ["ES2020", "dom", "node"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| declare module "MANIFEST" { | ||
| export const components: any[]; | ||
| export const routes: any[]; | ||
| export const Layout: any; | ||
| export const ErrorComponent: any; | ||
| } | ||
|
|
||
| declare module "ROOT" { | ||
| const root: any; | ||
| export default root; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,9 @@ export function sourcemap_stacktrace(stack: string) { | |
| return input; | ||
| } | ||
|
|
||
| const consumer = new SourceMapConsumer(raw_sourcemap); | ||
| // TODO: according to typings, this code cannot work; | ||
| // the constructor returns a promise that needs to be awaited | ||
| const consumer = new (SourceMapConsumer as any)(raw_sourcemap); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this whole file doesn't seem to be used anyway (copied from sapper). can we just delete it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps this is because Sapper uses before deleting this file we might want to test what happens if an error is thrown server-side in the production app. will the stacktrace be readable (i.e. sourcemapped) or will it be on the minimized code?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, it's a newer version; then the code most likely does indeed not work. It's non-trivial to change the code to be async, that's why I didn't do it. Should we downgrade in the meantime?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the stack traces: in dev mode, if I throw an exception in On the client side, it correctly says On a production build, the client-side stack trace from an error I throw in an The server-side stack traces look like: Is this worth a ticket? I'm not sure what expectations we have; neither of the stack traces is terrible, but it would of course be better if it mentioned the correct source file.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we had to stick to Yeah, it seems worth a ticket to source map the production server-side trace just as Sapper does today
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, created #76 |
||
| const pos = consumer.originalPositionFor({ | ||
| line: Number(line), | ||
| column: Number(column), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "resolveJsonModule": true, | ||
| "module": "esnext", | ||
| "moduleResolution": "node", | ||
| "target": "ES6", | ||
| "esModuleInterop": true, | ||
| "noEmit": true | ||
| }, | ||
| "include": ["src/**/*"], | ||
| "lib": ["ES2020", "dom", "node"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ module.exports = { | |
| 'src/setup': '/_app/setup' | ||
| }, | ||
| alias: { | ||
| '@sveltejs/kit': '/_app/main', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean the user has to build once to make TS happy because else the typings don't exist yet?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this configuration doesn't affect your development tools (this is the run-time module resolution). The (dev) dependency (It won't be able to resolve to the source code since it's only copied into place (in |
||
| $components: './src/components' | ||
| } | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snowpack's typings show it should be
utf8rather thanutf-8