tc39 / proposal-import-attributes

Proposal for syntax to import ES modules with assertions
https://tc39.es/proposal-import-attributes/
Apache License 2.0
569 stars 32 forks source link

Overwriting the headers instead of creating new custom syntax #107

Closed franciscop closed 3 years ago

franciscop commented 3 years ago

Sorry for being late to the party. My proposal is to, instead of creating a new way of naming a header, overwrite the Content-Type server-side header through this syntax:

import json from "./foo.json" with { "Content-Type": "application/json" };
import("foo.json", { "Content-Type": "application/json" });

Why?

This might seem similar as issue #85, but this issue is about overwriting the response headers, not about content type negotiation.

ljharb commented 3 years ago

There’s no such thing as a header in ecma-262, or in non-browsers (for non-http imports, that is)

bmeck commented 3 years ago

I would note that assertions do not allow alteration or overriding of the headers, they are merely an integrity check. Changing headers would go to a separate evaluators proposal : https://github.com/tc39/proposal-import-assertions#follow-up-proposal-evaluator-attributes

xtuc commented 3 years ago

@franciscop is that a satisfying answer to you? we discussed that in the past. Can I close the issue?

littledan commented 3 years ago

I think this proposal is a bit too low-level: it's more verbose and feels less likely to work the same across environments.

franciscop commented 3 years ago

"they are merely an integrity check"

Oh sorry I missed that from the proposal, then yes this is fine!