14:22
<Jack Works>
littledan: you may interested in this prototyping
14:23
<Jack Works>
implemented import(spec, { reflect: true }) in webpack
14:24
<littledan>
littledan: you may interested in this prototyping
Cool!
14:24
<littledan>
Ljharb, is there an issue tracking your concern?
14:24
<littledan>
Or Justin?
14:24
<ljharb>
for the module stuff?
14:25
<littledan>
Yes, the extensibility question
14:25
<littledan>
We need to have this discussion bringing everyone together. That was an important thing I learned today.
14:25
<ljharb>
my concerns came up during import assertions, and are very documented; i don't think i've documented yet how my fears exactly came true as predicted as tools tried to inject all sorts of wacky syntax forms into assertions
14:25
<ljharb>
if someone has a use case they should bring it to tc39, we don't provide programmable syntax
14:26
<littledan>
Right, can we move this discussion to an issue thread so you and Justin can lay out the arguments?
14:26
<Jack Works>
my concerns came up during import assertions, and are very documented; i don't think i've documented yet how my fears exactly came true as predicted as tools tried to inject all sorts of wacky syntax forms into assertions
and they use import x from "!raw-loader!./file.txt" in days before.
14:26
<littledan>
(I think it will get lost in this chat and this is a major thing for us all to follow up on)
14:27
<littledan>
(And, to be clear, I am Ok with either outcome)
14:27
<Justin Ridgewell>
There was an issue, and several other bundlers voiced the same concern as me.
14:27
<ljharb>
and they use import x from "!raw-loader!./file.txt" in days before.
yes, and the ecosystem recognized how terrible that is which is why it's been a bad practice to use webpack-specific loader syntax for a long time
14:27
<Justin Ridgewell>
The loader syntax didn't go away, it's just done in separate ways now.
14:28
<Justin Ridgewell>
Every bunder reinvents it for themselves
14:28
<ljharb>
extensible syntax is exactly every bundler reinventing it for themselves
14:28
<littledan>
yes, and the ecosystem recognized how terrible that is which is why it's been a bad practice to use webpack-specific loader syntax for a long time
It sounds like this remains a point of disagreement within the community maybe
14:28
<ljharb>
if we want to avoid that (which i think we do) then the actual use cases need litigating here
14:29
<littledan>
I don’t think any one of us could speak for the ecosystem any more than we can speak for TC39
14:29
<ljharb>
of course
14:29
<ljharb>
i'll qualify if it's really needed, "it seems like much of the ecosystem has"
14:30
<ljharb>
and to be fair i'm more talking about packages; it doesn't matter much what people do in their own apps
14:30
<Jack Works>
things become better after we have import.meta. Now many bundlers support new URL("./spec", import.meta.url) as a way to reflection and it also works in real browser
14:31
<nicolo-ribaudo>
I ideally would like bare JS to have the same capabilities as bundlers, except that bundlers also put everything in a single file
14:31
<nicolo-ribaudo>
It's nice to have image-loader in webpack, but I would also like it to work without webpack
14:32
<Jack Works>
I don't allow any loader in our project that convert any non JS files into a JS by import syntax unless the host can do that too (e.g. we allow JSON imports)
14:32
<Justin Ridgewell>
TC39 is not an appropriate place for all of the concerns bundler have to deal with, so I don't think that's possible
14:33
<nicolo-ribaudo>
Which concerns, for example? I guess code splitting, but that still falls under the "putting multiple things in the same file" category
14:34
<ljharb>
i don't mean that tc39 has to provide every semantic, since that isn't always possible, but it should still be discussed
14:35
<Justin Ridgewell>
  • Importing an image with blurry placeholder, intrinsic size, etc.
  • Import bytes buffers
  • Transforming files for the importer's usecase
  • Annotating metadata
    (these are just the things I did last week)
14:35
<nicolo-ribaudo>
  • Importing an image with blurry placeholder, intrinsic size, etc.
  • Import bytes buffers
  • Transforming files for the importer's usecase
  • Annotating metadata
    (these are just the things I did last week)
Well, for example Module/ModuleSource can solve the first three by providing custom module loaders
14:35
<Justin Ridgewell>
It's all module reflection. TC39 has a need for WASM (that I agree with!), and bundler have a much lager need. I'd like a single solution to the full problem space.
14:35
<ljharb>
and why do these need parseable syntax instead of a comment?
14:36
<Kris Kowal>
These are good reasons to allow userspace to do more without our permission, as would be possible with Module and ModuleSource.
14:36
<nicolo-ribaudo>
Well, for example Module/ModuleSource can solve the first three by providing custom module loaders
Ok I see: you would want to pass data from the import statement to the import hook
14:37
<nicolo-ribaudo>
And "the bundler" is equivalent to Module with a custom import hook
14:38
<littledan>
FWIW I lean towards what Justin is saying and sort of regret naming the keyword “assert” for that reason. I don’t feel like the assertion mental model resonates with anyone.
14:38
<Justin Ridgewell>
I don't understand the ModuleSource suggestion, relying on runtime evaluation means it's unacceptable for most of the web?
14:38
<Justin Ridgewell>
I can't have a bunder output that uses eval() in any form
14:38
<Justin Ridgewell>
It's going to immediately fail in CSP
14:39
<Kris Kowal>
Pardon module source with a lower case. Module blocks provide module sources with CSP annotation.
14:40
<nicolo-ribaudo>
I can't have a bunder output that uses eval() in any form
I am very sorry to reply with a link to a proposal that has not been presented in detail (other in in Kris' module harmony presentations), but with https://github.com/tc39/proposal-compartments/blob/master/2-virtual-module-source.md we could have custom sources - even not created from module blocks - without eval.
14:41
<littledan>
I would say, I don’t see why JSON modules shouldn’t have a source
14:41
<Luca Casonato>

I would say, I don’t see why JSON modules shouldn’t have a source

Yeah, they probably should - that is up to the HTML integration though

14:41
<Justin Ridgewell>
I mean, why can't WASM just do fetch().then(eval)?
14:42
<Justin Ridgewell>
Like, isn't that the same suggestion as using Comparentments/ModuleSource/etc?
14:42
<Justin Ridgewell>
The use case seems the same to me, and I'm saying its much larger than just WASM.
14:43
<ljharb>
FWIW I lean towards what Justin is saying and sort of regret naming the keyword “assert” for that reason. I don’t feel like the assertion mental model resonates with anyone.
if you're going to call out "ecosystem" as being too broad then i'll call out that "anyone" is excluding me, for whom it resonates very strongly :-)
14:44
<nicolo-ribaudo>

I cannot speak for the champions of compartments, but from what I see one major goal of that proposal is to allow writing safe runtime code:

  • either without eval (for example, with the virtual module sources I linked) - and this is what I'm most interested in
  • or with eval in a controlled way, because compartment could provide custom versions of the dangerous objects and properly confine the executed string
14:44
<Kris Kowal>
Like, isn't that the same suggestion as using Comparentments/ModuleSource/etc?
To be clear, new Module((module {}).source) is safe under CSP.
14:45
<Kris Kowal>
And the source in question is a module source and an instance of ModuleSource but not constructed by new ModuleSource(text)
14:45
<Justin Ridgewell>
Yes, but that doesn't solve the transform, reflection, custom behavior, because none of that is representable in a module {} block?
14:46
<Kris Kowal>
Correct. For that, Nicolò cites a proposal for virtual module sources, which would be able to do these things in JavaScript, without eval.
14:47
<Kris Kowal>
But to be clear, that proposal is a place-holder. We have a lot of work to do to make it viable.
14:47
<guybedford>
Justin Ridgewell: today, bundlers CANT bundle Wasm
14:47
<guybedford>
because there is no way to treat them as another node in the graph
14:47
<guybedford>
the ESM integration is not sufficient for most Wasm modules
14:47
<guybedford>
since it implies import maps support for things like wasi, which is simply not tractable in most scenarios
14:48
<Justin Ridgewell>
They can manually instantiate an array buffer, though.
14:48
<guybedford>
Wasm also does not support cycles, while Wasm import functions and memory bindings often rely on cyclical linkage
14:48
<Justin Ridgewell>
What's being suggested is a way to do it statically.
14:48
<guybedford>
manual instantiation is the reason bundling of Wasm is such bad UX right now
14:48
<guybedford>
look at any Wasm project
14:48
<guybedford>
and there's an option to set CUSTOM_WASM_URL
14:48
<Justin Ridgewell>
Right, which is my exact argument for everything else
14:48
<guybedford>
because the patterns are simply not supported
14:48
<Justin Ridgewell>
The problem space is more than WASM
14:49
<guybedford>
I would prefer not to be told what the problem space of my proposal is :)
14:49
<Kris Kowal>
The problem space is more than WASM
Agree very much.
14:49
<Justin Ridgewell>
The ergonomics that I need to support for my bundler has all of this other uses
14:49
<Justin Ridgewell>
I want (and other bundlers) want a solution that solves the full problem
14:50
<guybedford>
right, and that needs to be weighed against these use cases, but please don't make us overreach our use cases
14:50
<Kris Kowal>
Yes, I too have written bundlers. Agree very much that we need extension points and support from 262 for parity between dev and prod.
14:50
<guybedford>
we are solving specific problems we have clearly described
14:50
<guybedford>
a good way to start might be to hear what you are after more clearly
14:51
<guybedford>
perhaps you could present in the modules group what use cases you would like to solve
14:51
<guybedford>
and we can start to build discussion around how the use cases fit together
14:51
<Justin Ridgewell>
import module foo from 'wasm' => import foo from 'wasm' assert { type: 'module' }
14:51
<Justin Ridgewell>
That's all I want
14:51
<Justin Ridgewell>
Put reflection into an extensible syntax
14:51
<guybedford>
It's really much better if you describe your use cases first
14:52
<guybedford>
instead of jumping to a specific syntactical change request
14:52
<Justin Ridgewell>
https://matrix.to/#/!wbACpffbfxANskIFZq:matrix.org/$4W15943K1Vb8Qmw5k-dTksp2GvxQbzW2CYRX-632J6o?via=matrix.org&via=mozilla.org&via=igalia.com
14:52
<Justin Ridgewell>
I've descrcibed the use cases every time you've brought up the proposal
14:52
<guybedford>
ah sorry I missed that
14:53
<Kris Kowal>
All of your cases are addressable in the fullness of harmony. Would be delighted to spend some time with you on that.
14:53
<guybedford>
what is the reason, you need overlap on this with assertions though?
14:53
<guybedford>
I can appreciate your wanting to use it, but not why our proposal should have to be shoehorned into it?
14:53
<Kris Kowal>
Well, good point, except for overlapping with assertions.
14:53
<Justin Ridgewell>
assert is badly named, it's extensibility that I want.
14:54
<Kris Kowal>
That extensibility can be satisfied fully by other means.
14:54
<yulia>
i also feel like it could have been named differently, but that has past -- does everyone have objections to with?
14:54
<yulia>
because i don't fully understand those objectsions
14:55
<Kris Kowal>
Well, renaming to with doesn’t answer Justin’s question. We’re not also proposing that arbitrary flags would be threaded thru with syntax into hooks.
14:55
<Justin Ridgewell>
Because it's all reflection. I think having a specific syntax and an extensible syntax that could accomplish the specific need is the incorrect way to solve the problem
14:56
<yulia>
im not suggesting a rename, but we have a number of specializations of loading that we want to do, and i don't think that the import + keyword really works, especially for dynamic import
14:56
<Justin Ridgewell>
(I need to go walk my dog, will check back afterwards)
14:56
<yulia>
plus this is extra stuff to learn for developers
14:56
<yulia>
whereas we've already introduced this new pattern with asserts
14:56
<Kris Kowal>
And I am adamant that extensible flags should not be threaded into import hooks because it reduces clarity of caching semantics across modules.
14:57
<Kris Kowal>
But I’m very supportive of having out-of-band metadata that clarifies the behavior of importing specifier patterns in a scope.
14:57
<yulia>
im not sure i am arguing for extensible flags, rather i support reconsidering how we expose this
14:57
<ljharb>
i also feel like it could have been named differently, but that has past -- does everyone have objections to with?
yes, i'm very opposed to extensible syntax in unknowable ways that will fork the language
14:57
<Justin Ridgewell>
(my own hot take, import assertions are already reflection mixed with assertion, import foo assert {type: 'json'} does reflection because it's generating a module from non-JS)
14:58
<yulia>
assertions can already be arbitrary
14:58
<yulia>
they are determined by the host
14:58
<Justin Ridgewell>
yes, i'm very opposed to extensible syntax in unknowable ways that will fork the language
This already exists in the ecosystem
14:58
<Kris Kowal>
As with Jordan, I’m in support of using with as a namespace 262 can extend, but not user code.
14:58
<ljharb>
assertions can already be arbitrary
they're not allowed to change the representation of the module, per spec
14:58
<yulia>
that is what json does
14:58
<ljharb>
This already exists in the ecosystem
in the specifier, or via comments, sure. are there other ways?
14:58
<yulia>
a json file, imported as a module, will not make sense
14:59
<ljharb>
of course it does
14:59
<ljharb>
it's how node has worked for well over a decade
14:59
<ljharb>
it's just that browsers have a security constraint that requires the explicit assertion
14:59
<yulia>
when you import the default namespace you get an error
14:59
<ljharb>
it's not changing the module's representation
14:59
<ljharb>
you get an error, but the spec doesn't require it
14:59
<ljharb>
and node originally was supposed to have the assertion be optional
14:59
<yulia>
import isn't a keyword in json, neither is export -- we are doing an extra step
14:59
<ljharb>
(a single collaborator obstructed that)
14:59
<yulia>
its not just a host level assertions
15:00
<ljharb>
it's not a keyword in css or html either but those were candidates for Modules too
15:00
<ljharb>
i don't think that's a realistic rubric to apply
15:00
<ljharb>
the JS ecosystem has imported JSON for over a decade via require('./path/to/file.json'). it's well-understood and quite intuitive
15:00
<yulia>
im not sure what the rubric is here. i believe css was already spec'd html (or i was asked to review it recently anyway)
15:01
<ljharb>
i'm saying that "you can import something" doesn't have a requirement that it be exported from the source, unless the source is a module format that requires explicit exports
15:01
<yulia>
the JS ecosystem has imported JSON for over a decade via require('./path/to/file.json'). it's well-understood and quite intuitive
yes, but it is unrelated to what modules do. that require works very differently from the beginning
15:01
<ljharb>
i don't agree that's true in user's mental models
15:01
<yulia>
user mental models are not what we are discussing?
15:01
<ljharb>
obv they're different under the hood, but that's irrelevant
15:02
<ljharb>
oh, that's what i'm discussing
15:02
<ryzokuken>
Christian Ulbrich: ping regarding importing JSON (we discussed it extensively the other day)
15:02
<ljharb>
sorry if i miscommunicated
15:02
<yulia>
you said no splitting of the language -- but you don't consider this to be a split? json != js
15:02
<ljharb>
no, i don't. wasm != js too
15:03
<ljharb>
i mean that when it's javascript i want things to be maximally universal, and tool-specific programmable syntax isn't
15:03
<Kris Kowal>
i think jordan’s concern is about emergent behavior of the ecosystem, producing further partitioning in what in npm is usable in various environments.
15:03
<yulia>
ok, i understand. I don't know if blocking syntax like with in favor of import module is the right choice though
15:03
<yulia>
there are other ways to do restriction and maximal compatibility
15:04
<ljharb>
maybe not. but even with the semantic restrictions on assert, there were tools who planned to abuse it for extensible syntax, until they got pushback
15:04
<yulia>
I had explicit feedback from developers to not continue to complicate import syntax
15:04
<ljharb>
"people want to do X" is not an automatic justification for providing a way for them to do X, and imo if the X is a good idea, it can be discussed in TC39
15:04
<yulia>
im even not sure if we should add something like with or if we should really just expand on assert because its already getting confusing
15:05
<ljharb>
for developers (not tool devs), extensible syntax is still more complex because it means there's more semantics to learn from more places
15:05
<yulia>
ok, yes -- but we already have assert { ... } and users are already learning it
15:05
<ljharb>
iow i maintain that the confusion isn't about parsing, because humans don't parse that way, but it's about "understanding what the code does" - and extensible syntax makes that harder
15:06
<yulia>
if we then add import lazy and import module i am not so sure
15:06
<Kris Kowal>
im even not sure if we should add something like with or if we should really just expand on assert because its already getting confusing
I’m open to managed extensions to the assert namespace, even for things that aren’t assertions, if that’s less burden on developers. I could even see a migration from assert to with if we require them to be equivalent. But only as long as those properties continue to be unavailable to import hooks.
15:06
<ljharb>
the semantics of assert are always "either it works or it throws"
15:06
<ljharb>
that is very easy to learn
15:06
<Christian Ulbrich>
yulia: But as I've said, in TS, there already is a special syntax for special imports, called type imports, and it is written like that: import type { MyType } ... so for at least TS developers this would not be different, but I also object to the wording/naming of module.
15:06
<ljharb>
you might have to figure out what the various assertions are, but you don't have to figure out what they do
15:07
<Kris Kowal>
the semantics of assert are always "either it works or it throws"
And I am in favor of maintaining this invariant because the alternative is to complicate cache keys and how singletons are shared between modules in the same scope.
15:07
<yulia>
yulia: But as I've said, in TS, there already is a special syntax for special imports, called type imports, and it is written like that: import type { MyType } ... so for at least TS developers this would not be different, but I also object to the wording/naming of module.
if we had types, then i would expect them to be imported like anything else. It doesn't seem to have the same level of modification as what import module/lazy might do
15:07
<yulia>
so this would be doubly confusing
15:07
<yulia>
because in one case you are declaring what you are importing, in another you are declaring how
15:08
<ljharb>
if we had types with no runtime semantics, you'd want them syntactically marked, so you could strip them easily
15:08
<yulia>
we should be very intentional about the right side and the left side of the expression is me point
15:08
<Kris Kowal>
yulia: But as I've said, in TS, there already is a special syntax for special imports, called type imports, and it is written like that: import type { MyType } ... so for at least TS developers this would not be different, but I also object to the wording/naming of module.
I’m okay with changing the syntax of import reflection for various reasons, but I can attest that living inside of the resulting universe with module blocks, import module begins to look familiar. The keyword module implies the production of Module instances in a very general way.
15:08
<yulia>
if we have import module/source/lazy whatever -- we should not have import type
15:09
<Kris Kowal>
To wit, if we renamed module to something like moduleInstance, it would also make sense to use moduleInstace {} as the introducer for module expressions.
15:10
<Kris Kowal>
if we have import module/source/lazy whatever -- we should not have import type
I would make the looser statement that some combinations will necessarily fail at various times for various reasons.
15:10
<yulia>
my thoughts on this are strong -- we should not be changing the role ad hoc. it makes it harder to learn
15:11
<Kris Kowal>
And of those parts, I’m regretfully least attached to lazy.
15:11
<Kris Kowal>
Does the strength of your conviction extend to precluding WASM from participating in the ESM graph?
15:11
<yulia>
Thats a shame, as it exists and provides backing for your other proposals and could help resolve this
15:11
<ljharb>
finite syntax seems much easier to learn than any extensible syntax imo
15:12
<yulia>
Does the strength of your conviction extend to precluding WASM from participating in the ESM graph?
why would i preclude that?
15:12
<yulia>
we aren't proposing import wasm
15:12
<yulia>
in which case i would ask why we didnt do import css, import json etc.
15:12
<Kris Kowal>
why would i preclude that?
I must be misunderstanding your objection. Are you objecting to JSON participating in the ESM graph?
15:12
<yulia>
and then, import type would make sense in the current scheme we created
15:13
<yulia>
I must be misunderstanding your objection. Are you objecting to JSON participating in the ESM graph?
nope, i am just pointing out that this exists
15:13
<yulia>
i am objecting to mixing roles and making additional syntax for developers to read, without being strict about what different parts of the import statement mean
15:14
<yulia>
yes, with is potentially extensible, but we are potentially, as a committee, going to add more of these
15:14
<Kris Kowal>
I’m in favor of opening the field for more types of modules.
15:14
<Kris Kowal>
i am objecting to mixing roles and making additional syntax for developers to read, without being strict about what different parts of the import statement mean
Okay, we don’t disagree.
15:14
<Kris Kowal>
yes, with is potentially extensible, but we are potentially, as a committee, going to add more of these
I’m in favor of 262 managing with and assert.
15:14
<yulia>
great, i was hoping this wasn't going to be controversial -- people should be able to rely on past knowledge
15:14
<ljharb>
i agree - but "extensible syntax" is the opposite of being strict about what different parts of the import statement mean
15:15
<yulia>
we can potentially be strict about with
15:15
<ljharb>
or rather, userland-extensible
15:15
<ljharb>
syntax that only we extend is ofc fine (since technically that's "everything")
15:15
<yulia>
we delegated behavior of assert to the host
15:15
<ljharb>
not all behavior
15:15
<yulia>
and, i am not so pedantic about this, we can have stuff on the left hand side, we just have to be really intentional here
15:15
<ljharb>
it's tightly constrained, by design
15:16
<ljharb>
hosts are only allowed to reject or not based on assert; they can't provide different representations based on it
15:16
<yulia>
ok, lets pick this up tomorrow maybe, it doesnt sound like we have a huge gulf of disagreement
15:16
<yulia>
hosts are only allowed to reject or not based on assert; they can't provide different representations based on it
they can and do given that css exists?
15:17
<yulia>
yes, we reject based on the mime type, but these don't get parsed as javascript
15:17
<Kris Kowal>
Okay, I think ljharb, yulia, and I are in agreement about the role of with/assert syntax in import statements and the open question is how to satisfy Justin’s request for extensibility. He’s clear about the requirements and we should be clear about alternative paths to simply forwarding a KV bag from syntax to import hooks.
15:17
<ljharb>
"parsed as javascript" isn't the constraint. it's "you can only ever get one representation of a specifier"
15:17
<Kris Kowal>
My concrete suggestion is that the mapping should occur out of band, in an import map or similar.
15:17
<yulia>
that sounds like a good path forward
15:18
<ljharb>
tbh i wish import assertions hadn't landed, out of band would have been much better. i think env-specific or tool-specific needs should be met outside the source code.
15:18
<Kris Kowal>
Yes. There must only be one representation per specifier (or the reflection thereof which I believe should be universal)
15:18
<yulia>
yes that aligns with the current reality and i think im fine with that. and i think my concern (though not justins) is resolved with what we just discussed
15:21
<Kris Kowal>
Hey, you know what’s cool about circadian rhythms? Whenever the sun rises, your ability to go to sleep stops, but your need for sleep continues!
15:22
<Kris Kowal>
If this persists for, say, a few cycles, the whole world starts to feel like an IKEA with no exit.
15:26
<Justin Ridgewell>
im even not sure if we should add something like with or if we should really just expand on assert because its already getting confusing
Having both with and assert is going to lead to confusion about which key-value goes where.
15:28
<Justin Ridgewell>
you might have to figure out what the various assertions are, but you don't have to figure out what they do
But you do. You have to know that assert { type: 'json' } turns into a default import of an object (and no named imports). type: 'css' gives you a StyleSheet and no class names, etc. These are already reflections mixed with asserts.
15:30
<Kris Kowal>
In both cases, the hint does not need to be expressed in syntax and can also be expressed elsewhere.
15:30
<Kris Kowal>
In the case of JSON, the behavior is indicated either by extension or MIME type depending on the medium. It could also be hinted in an import map.
15:30
<ljharb>
But you do. You have to know that assert { type: 'json' } turns into a default import of an object (and no named imports). type: 'css' gives you a StyleSheet and no class names, etc. These are already reflections mixed with asserts.
That’s not what they do, that’s what the modules are.
15:31
<ljharb>
json doesn’t “turn into” that, that’s what it always is
15:31
<Justin Ridgewell>
I don't understand, neither is JS so some reflection must have happened.
15:31
<Justin Ridgewell>
The reason you think JSON => default export is because node did it already, right?
15:32
<Justin Ridgewell>
I want to do that for my bundler.
15:32
<ljharb>
no, because conceptually that’s what it is
15:32
<ljharb>
json is a single thing
15:32
<ljharb>
that’s what a default export is - the single thing that represents what a Module is
15:32
<ljharb>
named exports are just extra stuff a Module has
15:32
<Justin Ridgewell>
We still have to teach people that you don't get named imports with JSON
15:32
<snek>
remember that json is not always an object at the top level
15:33
<Justin Ridgewell>
I don't share your intution on this at all, these are both reflection of some source text
15:33
<ljharb>
i can’t believe most devs think of importing something as reflecting on source text
15:33
<Justin Ridgewell>
It's literally not JS, so it must have done some reflection?
15:34
<Justin Ridgewell>
I don't understand this viewpoint at all
15:34
<ljharb>
i don’t think most devs even think of the term “reflection” much, tbh
15:34
<Justin Ridgewell>
I turned non JS into a JS module
15:34
<ljharb>
but sure, the engine might be doing reflection. You didn’t.
15:34
<ljharb>
and it’s still not a js module
15:34
<ljharb>
it’s a js value that represents the module
15:34
<Justin Ridgewell>
Bundlers assueme a limited role of the host.
15:35
<ljharb>
any more than Object is a js function - it’s not, it’s c++ in most cases
15:35
<Justin Ridgewell>
So I am the host reflecting on these import for my users.
15:35
<ljharb>
ok but devs aren’t the bundler, they just use them
15:35
<Kris Kowal>
I turned non JS into a JS module
Hold my beer. I turned HTML into a reactive Lisp compiles down to JS.
15:35
<ljharb>
the bundler is reflecting, sure.
15:35
<ljharb>
but most devs aren’t the bundler and don’t and won’t think that way
15:36
<Justin Ridgewell>
Yet we're having to invent the syntaxes for them to do it, because the bundler can't know the correct use in every situation
15:36
<ljharb>
the prevailing mental model should be what most users reason about, which won’t likely match how implementers think
15:36
<Kris Kowal>
Hold my beer. I turned HTML into a reactive Lisp compiles down to JS.
And then I imported it in JavaScript, to be clear, so I could instantiate it. And I did it in the browser during development and in the bundler for production.
15:36
<Kris Kowal>
Which is to say, our wills are twins.
15:36
<Justin Ridgewell>
So they are having to think about it, in a really awful string specifier
15:36
<ljharb>
sure, or, they’re having to not do the thing they can’t express. Which is also a fine outcome.
15:37
<ljharb>
everything needn’t always be possible sans language changes
15:37
<Kris Kowal>
Oh, and the string specifier was simply ./something.html, where .html mapped to a transform that was indicated in the local package.json.
15:37
<Justin Ridgewell>
How?!
15:37
<Kris Kowal>
And the transform was brought in via the devDependencies.
15:37
<Justin Ridgewell>
Let's remove require('json') because that's not ES
15:37
<Justin Ridgewell>
Ergonmics are a core need for bundlers
15:37
<Justin Ridgewell>
I have to provide this ability to users, because they'll go somewhere else if I don't
15:38
<Justin Ridgewell>
Node had to allow importing JSON
15:38
<Justin Ridgewell>
ES had to allow importing JSON
15:38
<Justin Ridgewell>
We're here to solve the ecosystem's needs
15:39
<ljharb>
where else can they go if no bundlers can do it?
15:39
<ljharb>
We're here to solve the ecosystem's needs
yes, but not “all possible needs”, individual needs, one at a time
15:39
<Kris Kowal>
I think I’ve lost the crux of the argument.
15:39
<Justin Ridgewell>
Are we ignoring that the ecosystem invents their own languages and tools constanatly?
15:40
<Kris Kowal>
Near as I can tell, I want everything Justin wants and have a story about how to make it happen, but not necessarily identical proposed solutions.
15:40
<Justin Ridgewell>
There'll just be another tool that does the thing they need
15:40
<ljharb>
no, I’m saying that JS doesn’t have to become all things. If you want to invent a language, go for it
15:40
<annevk>
Kris Kowal: I would also appreciate a README.md or some such :-)
15:41
<ljharb>
imo some node collabs suffer from a similar problem; in a panic over “but what if people use something else” they end up trying to make node into something it shouldn’t be. if a better platform exists, good, people should go use it
15:41
<Kris Kowal>
I mean, pre-ESM, I did a thing called Guten Tags https://github.com/gutentags/gutentag which did transforms on the fly in dev (in the browser) and folded them into a bundle for prod. That’s where I’m starting. The loader was https://github.com/gutentags/system
15:42
<Kris Kowal>
The reason it’s relevant is that it was all async, so basically playing the CommonJS game with hands bound.
15:42
<snek>
imo some node collabs suffer from a similar problem; in a panic over “but what if people use something else” they end up trying to make node into something it shouldn’t be. if a better platform exists, good, people should go use it
I think this is slightly inaccurate, people can't just up and switch to deno or bun overnight
15:42
<ljharb>
👏 for the pun
15:43
<ljharb>
i agree, which is why the fear is unfounded
15:43
<snek>
aws can't just say tomorrow that lambda will be their own new runtime that isn't node
15:43
<ljharb>
which means “a competitor has X and we don’t” is almost never an urgent scenario
15:43
<snek>
but this doesn't mean node users shouldn't have new interesting stuff
15:43
<ljharb>
also true. But nothing is interesting, or a good design, merely because someone else has it :-)
16:01
<Justin Ridgewell>
https://github.com/tc39/proposal-import-reflection/issues/18 is where this was discussed before
16:05
<guybedford>
Justin Ridgewell: it seems like you just want to use import assertions for bundler metadata
16:05
<guybedford>
which understandably is a difficult thing to discuss in this committee, but of course you can do as you wish
16:05
<guybedford>
what I still don't understand is how this relates to import reflection
16:05
<guybedford>
I simply see no relation at all
16:07
<Justin Ridgewell>
What does "reflection" mean to you?
16:07
<Justin Ridgewell>
It's controlling runtime behavior of the module, that's a reflection to me.
16:08
<Justin Ridgewell>
Whether you lazy load, import unlinked, receive an array buffer, aren't those are all reflections?
16:09
<Justin Ridgewell>
All of it's metadata, but it's used to do something in the runtime
16:10
<guybedford>
we originally tried to define generic reflection when coming at this proposal, but at this point that is more of a design history than what the proposal represents now
16:10
<guybedford>
where we got to, with unification with module blocks and compartments, is the ability to get the uninstantiated module record
16:10
<guybedford>
that's the use case for JS and Wasm
16:11
<Justin Ridgewell>
What I'm objecting to is creating a specific syntax to solve this, when the extensible syntax already exists and can solve it just same.
16:12
<Justin Ridgewell>
I don't want to end up in the inevitable confusion about what keyword goes where
16:12
<snek>
is this the proposal for importing a module object instead of a module namespace
16:12
<Justin Ridgewell>
They're all reflections as I see it, and I want them to go into the same place
16:12
<littledan>
at some point, Justin and Jordan should sort of talk about it between them and work out a recommendation to make to Guy; it's not really fair for Guy to bear the burden of this disagreement
16:13
<littledan>
(sorry that's not to exclude other opinionated parties and co-champions of module reflection; they can join the battle and receive the results as well, but at least those people are affected)
16:14
<snek>
i think it makes sense to have a new syntax for uninstantiated module that doesn't need to be burdened with also being a whole generic system. (and as an aside, i still think people who want wasm modules instead of wasm module namespaces should not be using import anyway but 🤷)
16:15
<annevk>
I do think there's some value in being able to import something in various types. E.g., Blob vs ArrayBuffer comes to mind. But I don't have strong opinions on syntax (unless it's terrible :p)
16:15
<guybedford>
we did go through a lot of these cases when approaching reflection to try and see how it fits in with these use cases
16:16
<guybedford>
our eventual conclusion was that specifying these other types of reflections is very difficult because of host-specific semantics and the dififculty of getting agreement between hosts
16:16
<guybedford>
and that instead asset references would be the preferable approach
16:16
<guybedford>
with an opaque asset representation
16:17
<guybedford>
but this does not fulfill the requirements of import reflection for JS and Wasm modules, since it is not enough to know the asset, you need to know its modular interpretation
16:17
<snek>
the module blocks/compartments proposal has a load func or similar right?
16:17
<Justin Ridgewell>
I don't think we need to standardize the userland reflections
16:17
<guybedford>
so, we very much support work on asset references
16:17
<Justin Ridgewell>
Just the syntax, where implementers and bundlers can coexist
16:17
<guybedford>
as distinct from import reflection / module reflection
16:18
<snek>
it seems like it would be better to say that people should use like Module.load('foo') instead of import module 'foo'
16:18
<guybedford>
why have static import { name } from 'mod' at all?
16:18
<guybedford>
why not just have all dynamic import()
16:18
<guybedford>
and call it CJS?
16:19
<guybedford>
because there are benefits of static syntax
16:19
<guybedford>
we need those
16:19
<snek>
er
16:19
<snek>
its not about the static/dynamic ness
16:19
<snek>
its about confusion between the two use cases
16:19
<snek>
at least in my mind
16:20
<guybedford>
I'm not sure who's arguing what at this point tbh
16:20
<Justin Ridgewell>
I don't think having dynamic behavior solves the ergonomic need, because we could already do it
16:20
<Justin Ridgewell>
I agree with Guy's latest series of messages, and disagree with devsnek's.
16:20
<snek>
i don't have full context on what justin is asking for, i was just saying some general opinions i have about this proposal
16:20
<Justin Ridgewell>
Static analyzability is the reason this is nice to use
16:21
<Kris Kowal>
the module blocks/compartments proposal has a load func or similar right?
importHook could be called load with a clean conscience. The name reflects that it’s the one driven by import, but its responsibilities are limited to loading and either parsing or fabricating a fake module source out of code.
16:22
<snek>
yeah i just don't feel like, if we have that functionality, the additional import syntax is worth it
16:22
<Kris Kowal>
And assets can be solved either with a reflection or a virtual module source. There’s more than one way to bake that cake.
16:22
<snek>
imo import is for doing the module namespace dance, and reflection and other stuff should be separate
16:23
<Kris Kowal>
I personally favor having a single reflection of module instances, a variety of reflections of module sources per type, and leave assets to virtual module sources.
16:39
<guybedford>
I again invite everyone who has brought forward opinions here to attend the module harmony meetings
16:39
<guybedford>
the original meeting issue is at https://github.com/tc39/Reflector/issues/436
16:40
<guybedford>
this meeting was created exactly to work through the difficult cross-cutting questions
16:40
<guybedford>
I will make sure to attend as possible coming meetings as well
16:41
<guybedford>
bringing agenda items for what you want to see is a great way to start. I think things work best when you focus on your own specification work to get your own results, treating proposal interaction as an open discussion as opposed to a fixed constraint
16:41
<guybedford>
or more specifically, when you focus on the use case you want to solve, and then allow open discussion around that
17:22
<tolmasky>
Are there any (JavaScript) packages and/or APIs that allow you to get ECMA spec data in a structured way. For example, if I wanted to get the contents of the Well-Known Intrinsics Objects table (https://262.ecma-international.org/13.0/#table-well-known-intrinsic-objects) as JSON, so I could list them, etc.
17:49
<ljharb>
tolmasky: no, but there's https://github.com/tc39/proposal-get-intrinsic which will let you enumerate them
19:13
<bakkot>
tolmasky: there's https://www.npmjs.com/package/@tc39/ecma262-biblio, though note that it is inherently unstable - editors make revisions to the organization of internal operations frequently and without going through plenary
19:13
<bakkot>
it only covers the names, arguments, and types of abstract operations, though
23:58
<tolmasky>
bakkot: yeah that looks close, it mentions the table, but doesn't have the contents of the table. OK, I'll just copy it by hand