6 ms·
Interesting. I've never seen the import-with syntax, though and it's hard to find any documentation on it. Is this a syntax extension?
by Thom2000 1y ago
Interesting. I've never seen the import-with syntax, though and it's hard to find any documentation on it. Is this a syntax extension?
- nrabulinski 1y agoIt’s been introduced as part of ecmascript 2026 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- no_wizard 1y agoIt first started as an assert statement[0] for those who may have seen that, these type statements are an evolution out of that proposal. I do wonder if this makes the importable gets (via type: json) a reality like assert was going to. [0]: https://v8.dev/features/import-assertions https://v8.dev/features/import-assertions
- throwitaway1123 1y ago> I do wonder if this makes the importable gets (via type: json) a reality like assert was going to. Yes, the JSON modules proposal is finished. https://github.com/tc39/proposal-json-modules https://github.com/tc39/proposal-json-modules https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json https://caniuse.com/mdn-javascript_statements_import_import_...
- no_wizard 1y agoAn entire class fetch requests will go away with importable gets. I am excited for this
- porridgeraisin 1y agoIn node you could always require("food.json")
- no_wizard 1y agoNot what I am talking about though. I’m talking about in place of a fetch call, you could simply import a json response from an endpoint, there by bypassing the need to call fetch, and you’ll get the response as if it’s imported. It won’t replace all GET calls certainly but I can think of quite a few first load ones that can simply be import statements once this happens
- porridgeraisin 1y agoOhh right. That makes sense.