-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add application/javascript+module
mime to remove ambiguity
#322
Comments
application/javascript+module
mime to remove ambiguity from HTMLapplication/javascript+module
mime to remove ambiguity
We don't have any control over mimetypes here. I think IANA optimally, or maybe the WHATWG HTML repository in practice, would be a better place to go. WDYT about this proposal @domenic ? |
See whatwg/html#558. This doesn't seem to add any value besides some theoretical notion of what MIME types are supposed to be used for. |
@domenic there is disagreement on that:
|
I'm not sure of the current status of the suggestion to use a different MIME type for ES6 modules in browsers, but my last understanding was that this was the way browsers would know to pivot on it. From reading whatwg/html#443 it seems that's not likely. Would users only use |
The reasons in chat seem to be a domain problem more than anything, whilst I can sympathise, the fix isn't really a fix.. say the new extension gets the go ahead and what? you can start using that suddenly? you could have used it all along within your problem domain. To really solve your problem you need the ecosystem to agree, that source out of your control also plays into this scheme, but they won't.. why should they when the old default way exists and your domain problem doesn't affect them. At the company I work for we've spent the last 24 months writing source as ES6 with modules, and back then the how of all that would work within the browser was very in the dark, even today only just happening, we solved it within our domain with |
@meandmycode well the proposal in node is asking for a new filetype, and as such a new MIME nodejs/node-eps#3 . I am unclear on the "you could have used it all along within your problem domain." bit, if you could explain further. |
@bmeck sorry, by that I mean, within your domain you could have used whatever file extension of your own all along to help the files self identify themselves to your build / runtime. |
@meandmycode people are expressing concerns of using an unregistered file extension, though we do realize that it would be possible to do so. |
@bmeck yep, I realise that, but I think my point is that a new extension.. registered or otherwise really doesn't solve the problem described, say you used I feel by the time you would introduce and manage to convince an entire ecosystem of developers to follow a new extension, the original problem would have been long solved and we're left with another artefact. I should specify this is just based on my own experience, as a consumer developer, so don't take any of this as gospel. |
@meandmycode our goal is to be compatible with the module specs around TC39 and WHATWG and try to avoid being limited to our single domain. The problem comes from gammar ambiguity. Feel free to discuss this in the Node proposal as well if you think we don't need a new filetype. |
Closing this since it is not relevant to TC39. See https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for what are good ways to contribute to this repository. Individual communities can use whatever file extension or MIME type they want for their JavaScript. Neither WHATWG's HTML nor TC39's ES have any impact on this, except that HTML only accepts JavaScript MIME types to prevent e.g. reinterpreting an image or CSV as an executable script. (And even then, only for module scripts; classic scripts are looser.) It doesn't care about file extension. ES cares about neither and only provides top-level grammar productions to host environments. If people want to discuss registering a new MIME type with the IANA, they can, but that doesn't impact any real world software and in my personal opinion should not be a goal of anyone if it doesn't have developer-facing consequences. And that discussion shouldn't happen on this issue tracker. |
@domenic I'm not sure how this isn't a problem for the TC39. The current solution of depending on a DOM feature shuts out non-browser usage, and an alternative solution like using a different extension would break on the browser because it's an unregistered mime type. Thus shutting out scripts that could be compatible with both. So this move clearly shows there is no concern to support anything except the browser. |
@trevnorris TC39 does not deal with file extensions or MIME types. That is why it is not a problem for TC39. For all TC39 knows your code is fed to ParseModule and ParseScript via monkeys dictating it to the CPU through song. Each host environment is responsible for figuring out whether to call ParseModule or ParseScript. HTML as a host environment has one solution. But any other environment can come up with any other solution. TC39 is agnostic to what your environment uses. |
@domenic I'm not stating "this" as in the request for an additional mime type. I'm stating that there's been no thought as to a reliable/spec compliant way to detect a module. Thus removing avenues that allow the same file to be detected in browser and non-browser situations. |
TC39 has decided that the host environment can choose to detect a script or module depending on host-specific hints. TC39 just provides the two entry points and allows a given string to be parsed by both of them. The host environment can restrict certain strings from certain sources to only go through one entry point or another, but that's up to them. Really, you have complete freedom here, and should be glad you don't get your choices constrained by a standards body. This has been discussed many times on es-discuss over the years. If you would like to reopen those discussions, es-discuss is the place to do so. |
If anything, this should be |
@ExE-Boss thoughts on how |
@WebReflection |
@ExE-Boss so it would work and there would be nothing to do for anyone, right ? |
Right now whatwg/html#443 is overloading the
application/javascript
mime type for both script and module goals. This creates ambiguity in node if they share the same file extensions but cause different semantics. I suggest addingapplication/javascript+module
and a different filetype to remove this.The text was updated successfully, but these errors were encountered: