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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source map support #423

Closed
wants to merge 4 commits into from
Closed

Source map support #423

wants to merge 4 commits into from

Conversation

ry
Copy link
Member

@ry ry commented Jul 27, 2018

Depends on #421

@ry ry force-pushed the source_map branch 4 times, most recently from 87546d5 to a1f1bdf Compare July 27, 2018 17:21
@piscisaureus
Copy link
Member

@ry
Copy link
Member Author

ry commented Jul 28, 2018

Seems like you don’t have @types/node ?

if (!code) {
return null;
}
assert(typeof code === "string");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can narrow types in TypeScript by either leveraging call flow analysis, the way assert is written is a limitation of CFA and therefore doesn't narrow the type. If you did:

if (typeof code !== "string") {
  throw new Error("...");
}

After that block, code would be narrowed to string without needing re-assignment without a type assertion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - fixed.

@@ -2,8 +2,9 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
// Originated from source-map-support but has been heavily modified for deno.
import { SourceMapConsumer, MappedPosition } from "source-map";
import { RawSourceMap } from "source-map";
import * as base64 from "base64-js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not related to this PR, is there a reason for this? It is only used to encode to an array to convert to a string. Are btoa not available? If it isn't, it should be able to be exposed. One less dependency. 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure actually - I suspect it's redundant. This code is forked from source-map-support and base64-js was used there. I'd be happy to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think btoa is available - it's DOM api (node doesn't have it either).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piscisaureus thanks... Yeah I found the one about adding it in Node.js and a bit of discussion which led to essentially what is a one liner in Node.js for btoa. I guess it is already pulled in via source-map-support though and sort of trying to slimline the runtime is something that can be done down the road.

@ry
Copy link
Member Author

ry commented Jul 29, 2018

@piscisaureus Maybe your symlinks are messed up and it doesn't create //node_modules or //out/debug/node_modules ? Otherwise I'm not sure...

@ry ry force-pushed the source_map branch 4 times, most recently from e12ab6f to 4a5fe4b Compare July 29, 2018 04:30
@piscisaureus
Copy link
Member

@piscisaureus Maybe your symlinks are messed up and it doesn't create //node_modules or //out/debug/node_modules ? Otherwise I'm not sure...

Symlinks are fine. Running tsc directly also no problem, looks like something related to either ninja or rollup. Will look into it.

ry added 2 commits July 30, 2018 15:13
It's a dependency of js/v8_source_maps.ts.
Switch the order of the snapshot_creator args, in order to allow for
optional source map arg.
@ry
Copy link
Member Author

ry commented Jul 30, 2018

I have removed the asm optimization from this PR. I will submit separately.

This change increases compile time and size:

Compile time:
obj/libdeno/from_snapshot.o            44s -> 85s

Size:
out/debug/obj/libdeno/from_snapshot.o  19M -> 34M
out/debug/gen/snapshot_deno.cc         54M -> 97M
out/release/deno                       32M -> 47M

The compile time of from_snapshot.o is problematic and will be dealt
with in future commits.
@ry
Copy link
Member Author

ry commented Jul 31, 2018

closed in favor of #429

@ry ry closed this Jul 31, 2018
@ry ry deleted the source_map branch July 31, 2018 00:46
piscisaureus pushed a commit to piscisaureus/deno that referenced this pull request Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants