D3 external as script#71
D3 external as script#71gregmagolan wants to merge 3 commits intoangular:masterfrom gregmagolan:d3-external
Conversation
| cmd = "cp $< $@", | ||
| ) | ||
|
|
||
| genrule( |
There was a problem hiding this comment.
we should clean this up - can be in a later PR. the ts_devserver should have an option that allows us to serve additional rootdirs, I think this is already present but maybe not wired up?
| @@ -0,0 +1,3 @@ | |||
| <div>Hello {{ name }}</div> | |||
| <input type="text" [value]="name" (input)="name = $event.target.value"/> | |||
There was a problem hiding this comment.
we need an actual example app. I'll ask in the GDE channel to see if we can get something good
src/typings/shims.d.ts
Outdated
| @@ -0,0 +1,5 @@ | |||
| import * as _d3 from 'd3'; | |||
|
|
|||
| declare global { | |||
There was a problem hiding this comment.
if we check this in, it needs a bunch of comments explaining what this is, how to use it, how to formulate one for a different library, etc. - since this is the canonical example
There was a problem hiding this comment.
I will add some comments
src/typings/BUILD.bazel
Outdated
|
|
||
| load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") | ||
|
|
||
| ts_library( |
There was a problem hiding this comment.
I'm not sure this merits a whole separate bazel package - why not put the shim in something like typings.d.ts in the src/ directory?
There was a problem hiding this comment.
That would work. I like having them in their own folder but a single typings.d.ts file will do the trick.
| // any ts_library or ng_module that requires these types and it makes them available | ||
| // as global variables that are properly typed in typescript. | ||
| declare global { | ||
| const d3: typeof _d3; |
There was a problem hiding this comment.
I feel like this is the opposite of what we want, long-term -- we want users to import d3 if they use it, so that taze can add the proper dependency when needed.
There was a problem hiding this comment.
Alex and I both agree that we need another example with d3 imported properly. This example is the only way that works at the moment with where ts_devserver and the rollup_bundle production bundler is at right now. Getting it to work with an import will require changes to both and needs to some thought.
There was a problem hiding this comment.
@evmar my understanding is that some libraries are documented such that developers expect to import them, but some are only accessible via globals. I think ABC needs to demonstrate both ways? If we only document how to use ES imports then I think some libraries would be unusable?
There was a problem hiding this comment.
I think the typings usually match how the library works, so you only need a shim thing like here when you're using the library in a way contrary to its intended use.
There was a problem hiding this comment.
@gregmagolan I'm hesitant to merge this if the intended use of d3 is to import it.
What's a library that provides a better test case for ambient imports?
There was a problem hiding this comment.
I don't know of one off the top of my head. I'll think about it.
|
I guess this is dead, and we'll use ngrx as the third-party library example |
No description provided.