Repository navigation
Design Meeting Notes, 6/4/2021 #44442
Description
Activity
- addedDesign NotesNotes from our design meetingsNotes from our design meetings
on Jun 4, 2021 mjs/cjsis fornode.jsonly, not for browsers ordenocommonjsnever be a part ofECMAScript, not supported in browsersmjsinnode.jshave some behavior not support in browsers, it's notpure ECMAScript- most of the use-case of
JSXis forhtml in browser
So, I think there is no need to support
JSXinmjs/cjs
I'm not a team member, I guess this issue is comment allowed, let me know if it's not, I'll delete this.
Reacted by ExE Boss, Adam Russell and Lars ArtmannReacted by GoToLoopmjs in node.js have some behavior not support in browsers, it's not pure ECMAScript
Can you clarify on this point? Browsers don't care about file extensions (only mimetypes), and IIRC module specifier resolution is implementation-defined per ECMAScript. I don't think there's anything non-standard there?
Reacted by GoToLoopTry to say it clear, I mean the code might be an ECMAScript-module, but it doesn't mean they have the same implementation:
// this line won't work in the browser import fs from 'node:fs/promises'; // this line won't work in node.js import func from 'http://example.org/test.js';
For a long time, we don't know
*.jsis ready for who, browser or node.js
But now we know*.mjs/*.cjsis for node.js only.I thought
JSXis a sugar designed to make HTML binding easier, it's for browser only.But now I realize
JSXis used in many SSR projects. run them innode.jsis possible, I should change my mind.Reacted by Adam RussellBenBeattieHood commented
on Oct 18, 2022 More actionsHas there been any further decision on the adoption of an
.mtsxextension?Reacted by silverwind and TomásReacted by Norman Fuchs, Jayden Seric, Aleksander Heintz, Arek, Colin McDonnell, Vitor L Cavalcanti, peelz, Abhijeet Singh, GoToLoop, Wouter Klijn and 1 moreI'd love for TS to recognize both ".mtsx" & ".ctsx" file extensions!
Possibly emit them as ".mjsx" & ".cjsx" respectively.Reacted by silverwind and Tomás- added a commit that references this issue
on Jan 12, 2023 There is still no way now more than 2 years after this discussion to indicate in a CommonJS React project that a specific file is a TypeScript MJS module making it impossible in a TypeScript CJS application to use any ESM only dependency which now means
react-dnd(the primary drag and drop utility) is no longer accessible to the majority of ReactJS apps as it has gone ESM only (ARGGGGGGGGG WHY!!!!!).I am forced to use a
.mjsfile and completely remove all typing from my file and then use a combination of Suspense and Lazy to load it as a component in a CJS file.Reacted by Tomás and Evan LovelyReacted by TomásThere is still no way now more than 2 years after this discussion to indicate in a CommonJS React project that a specific file is a TypeScript MJS module
Wish there was a solution here; anybody have one?
ES Modules in Node
https://gist.github.com/weswigham/22a064ffa961d5921077132ae2f8da78
.tsxsyntax and how it affected JS module support..cjsand.mjsneed a corresponding input format for them..ctsand.mts.jsx->.tsx.mjsx->.mtsx?.mts..mjsxa thing?.mjscan contain JSX..jsfiles we always parse JSX anyway..cjsand.mjsallowJs.jsfiles..cjsx,.mjsx..jsand.jsxin today's implementation?.ctsand.mtsextensions.cjsand.mjsrespectively..cjs" and "emit as.mjs" from.tsinput..ctsxand.mtsx?.ctsincludes JSX,.mtsincludes JSX.<Type>expression)expression as Type<T>(x: T) => x)<T,>(x: T) => xor<T extends unknown>(x: T) => x>in the arrow is not illegal..cjsfor React? It sounds like a Node-ism..ctsand.mtswithout JSX support and add it later..tssyntax conflicting with JSX syntax.let x = <Foo>yadda;- have to disallow thislet f = <T>(x: T) => x;- have to disallow this<T>3</T>// @jsx: true.tsx->.mtsbeing weird...but works better for.ts->.mts..mtsand.ctsparsed as.ts, additional grammar error to inform people of what you meant if you wrote specific constructs..cjs,.mjs.d.cts,.d.mts.d.mtsif you import with an.mjsextension, right?.d.tson?