Comments (16)
I think we came to a conclusion to add braces. I sent a PR and once it's merged we will close this issue. Thanks
from proposal-import-attributes.
Personally, I'd like to minimize the number of analogous cases we introduce. I think each one adds a bit of confusion. So, I'd prefer to omit the braces.
from proposal-import-attributes.
there'd likely be a comma there:
import { foo } from 'foo.js' with type: "json",
foobar: "baz";
from proposal-import-attributes.
I think the argument for wanting braces/adding familiarity of syntax is less compelling if the non-brace syntax still allows copy pasting albeit requiring a wrapping {/*paste here*/}
. I'm fine on either, just pointing out that the usability concern of braces enhancing copy/paste between locations seems somewhat weak.
from proposal-import-attributes.
Personally, I still prefer the no-brackets notation, but I'm open to using the brackets here.
I'd like to propose that, while the choice of a key-value notation is pretty core for Stage 2, the question of whether or not we use brackets is a more detailed/superficial decision, which we could continue debating and conclude for Stage 3. Do folks agree?
from proposal-import-attributes.
In addition to having nice symmetry for import expressions, I believe braces or other delimiters are actually required to preserve future potential for solving things like #56 (i.e., the trailing comma case mentioned above). The no-braces syntax cuts off too much IMO.
from proposal-import-attributes.
I don't think the question of braces vs. no braces should block Stage 2.
from proposal-import-attributes.
No-braces syntax could be even more confusing. Also we already use curly braces in imports and they are not an object destructuring.
from proposal-import-attributes.
I'm in favor of this. I agree with @justinfagnani on readability. Besides that (as I mentioned in #3), this look pretty similar to dynamic import variant and if attributes line is very long, than multiline attributes should be considered.They look better with curly braces (this also makes trailing comma possible).
from proposal-import-attributes.
There's an ASI hazard without braces:
import { foo } from 'foo.js' with type: "json"
foobar: "baz";
labels (while rare) can't be differentiated. Is it supposed to be { type: "json", foobar: "baz"}
or { type: "json" }; foobar: "baz"
(a labeled string statement).
If we consider this to be arbitrary metadata proposal, it becomes more likely that we'll have multi-line metadata, making this more likely to hit.
from proposal-import-attributes.
@gibson042 I guess I'm still not convinced that we shouldn't solve that within the key/value-only syntax. Nevertheless, I'm not extremely against brackets, it's more of a minor preference.
Do you think we need to resolve this brackets-or-no-brackets question before Stage 2, or can we continue discussing it between Stage 2 and 3?
from proposal-import-attributes.
I don't have a preference for braces vs no braces, but I'm not convinced that braces would address #56.
In general, my understanding is that braces seems to allow better UX because of copy pasting, traling comma or being closer to the dynamic import. My only concern is that the static restriction on value will confuse developers that think it's just an object.
from proposal-import-attributes.
I think as long as the attributes are able to be wrapped in {}
to become an Object literal it seems a fair tradeoff to allow some copy pasting.
from proposal-import-attributes.
@bmeck I am trying to understand; does this mean you would be OK both with or without braces?
from proposal-import-attributes.
Thanks for clarifying. I think this matches my intuition as well.
from proposal-import-attributes.
Ahhh, you’re right.
from proposal-import-attributes.
Related Issues (20)
- Broken references in import assertions
- There should be an escape hatch to allow unknown import attributes HOT 3
- Tracking feasibility of unshipping `assert` contextual keyword in Chrome HOT 8
- No need for NLTH with `with` keyword HOT 9
- Stage 3 reviews HOT 15
- Inferring module type from MIME type vs `type` attribute needs clarification HOT 7
- Changes due to stage 3 reviews to present in July 2023 HOT 2
- return of dynamic import() HOT 1
- Invalid attributes keys in static imports should be a resolution/loading error and not a parsing error HOT 5
- Consider restricting attribute keys syntax to identifiers and strings again HOT 12
- Adding WPT tests HOT 2
- Restrict generalization by scoping private keys HOT 2
- how to use this feature in browser without polyfil? HOT 5
- Support gating with Progressive Enhancement or Graceful Degredation HOT 4
- Importing arbitrary files as raw bytes HOT 1
- Trouble with JSON Imports in JavaScript HOT 4
- [spam]
- [spam] HOT 1
- [spam]
- [spam]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-import-attributes.