TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

ES modules are terrible

172 点作者 theprotocol超过 3 年前

36 条评论

xg15超过 3 年前
&gt; <i>And then people go &quot;well you can statically analyze it better!&quot;, apparently not realizing that ESM doesn&#x27;t actually change any of the JS semantics other than the import&#x2F;export syntax, and that the import&#x2F;export statements are equally analyzable as top-level require&#x2F;module.exports.<p>...<p>&quot;But in CommonJS you can use those elsewhere too, and that breaks static analyzers!&quot;, I hear you say. Well, yes, absolutely. But that is inherent in dynamic imports, which by the way, ESM also supports with its dynamic import() syntax. So it doesn&#x27;t solve that either! Any static analyzer still needs to deal with the case of dynamic imports somehow - it&#x27;s just rearranging deck chairs on the Titanic.</i><p>I think while OP&#x27;s right in theory, there is still a lot of difference between the two: ESM has dedicated syntax for static loading of modules and that syntax is strongly communicated to be the standard solution to use if you want to load a module. Yes, dynamic imports exist but they are sort of an exotic feature that you would only use in special situations.<p>In contrast, CommonJS imports are dynamic by default and only happen to be statically analysable if you remember to write all your imports at the beginning of the module. That&#x27;s a convention that&#x27;s enforced through nothing and is not part of the language or even of CommonJS.<p>As an exercise, try to write a static analyser that simply ignores dynamic imports and just outputs a dependency graph of your static imports - and compare how well this works with CommonJS vs ESM.
评论 #29138814 未加载
评论 #29139402 未加载
评论 #29138711 未加载
评论 #29138971 未加载
评论 #29138808 未加载
评论 #29138695 未加载
评论 #29138917 未加载
评论 #29142379 未加载
评论 #29138953 未加载
spankalee超过 3 年前
This post is terrible, actually.<p>CommonJS was <i>never</i> going to be natively supported in browsers. The synchronous require semantics are simply incompatible with loading over a network, and the Node team should have known this and apparently (according to members of TC39 at the time) were told their design would not be compatible with future a JS module standard.<p>So the primary thing that JS modules fix is native support, and for that you need either dedicated syntax or an AMD-style dependencies &#x2F; module body separation. AMD is far too loose (you could run code outside the module body), so dedicated syntax it is.<p>Everything else flows from there. I really hate how people blame the standards instead of the root cause which is Node not having taken the browser&#x27;s requirements into consideration. Culturally, I think that&#x27;s mostly fixed now, but it was a big problem early on in Node&#x27;s evolution.
评论 #29141109 未加载
评论 #29145210 未加载
评论 #29144574 未加载
aravindet超过 3 年前
There is a valid discussion to be had about whether the Node.js ecosystem disruption of moving from CJS to ESM is worth the benefits, but the assertion that it&#x27;s technically worse isn&#x27;t accurate. A few things ESM does better <i>in Node.js</i>:<p>1. Asynchronous dynamic import() vs. blocking require(): allows the program to continue while a module is being dynamically loaded.<p>2. Circular dependencies: ESM correctly resolves most of them, while CJS does not. [example below] I believe this is possible because ESM top-level imports and exports are resolved <i>before</i> JS execution begins, while require() is resolved when called (while JS is already executing.)<p>3. Reserved keywords `import` and `export` vs. ordinary identifiers require, exports and module: Allows tooling to be simpler and not have to analyze variable scope and shadowing to identify dependencies.<p>I haven&#x27;t really encountered #3, but I can say I&#x27;ve benefited from #1 and #2 in real-world Node.js projects using ESM.<p>----<p>Circular dependencies example:<p><pre><code> &#x2F;&#x2F; a.js const b = require(&#x27;.&#x2F;b.js&#x27;); module.exports = () =&gt; b(); &#x2F;&#x2F; b.js const a = require(&#x27;.&#x2F;a.js&#x27;); module.exports = () =&gt; console.log(&#x27;Works!&#x27;); a(); </code></pre> Running this with &quot;node b.js&quot; gives &quot;TypeError: b is not a function&quot; inside a.js, while the equivalent ESM code correctly prints &#x27;Works!&#x27;. To solve this in CJS, we have to always use &quot;named exports&quot; (exports.a = ... rather than module.exports = ...) and avoid destructuring in the top-level require (i.e. always do const a = require(...) and call it as a.a() elsewhere)
TekMol超过 3 年前
ES Modules are great. Building JS applications is so much speedier, leaner and more fun now that they are supported widely.<p>One fallacy the author falls for is that they think one needs a build step &quot;anyway&quot; because otherwise there would be too many requests to the backend.<p>Loading an AirBnB listing causes 250 requests and loads 10MB of data.<p>With a leaner approach, using ES Modules, the same functionality can be done with a fraction of those requests. And then - because not bundled - all the modules that will be used on another page will be cached already.<p>I use ES Modules for all my front end development and I get nothing but praise for how snappy my web applications are compared to the competition.
评论 #29141167 未加载
评论 #29138998 未加载
评论 #29138981 未加载
评论 #29145262 未加载
评论 #29138994 未加载
andrew_超过 3 年前
I really, really loathe how major packages in the ecosystem are &quot;We&#x27;re ESM now, deal with it, sorry about your luck,&quot; and forcing the issue. It&#x27;s arrogant as hell. A hard fork of Node for ESM would have been a much better path (e.g. Deno) That said, the OP&#x27;s rant is more emotion than fact.<p>&gt; And then there&#x27;s Rollup, which apparently requires ESM to be used, at least to get things like treeshaking. Which then makes people believe that treeshaking is not possible with CommonJS modules. Well, it is - Rollup just chose not to support it.<p>Rollup was created specifically for ESM. It&#x27;s not been thrust onto the ecosystem or into anyone&#x27;s tool chain. One uses it specifically for ESM, and plugins that bolt on for added functionality if they apply. Trying to hammer a nail with a paintbrush doesn&#x27;t make the paintbrush a bad thing - you just chose the wrong tool.
评论 #29139460 未加载
davnicwil超过 3 年前
&gt; for some completely unclear reason, ESM proponents decided to remove that property. There&#x27;s just no way anymore to directly combine an import statement with some other JS syntax<p>This is one of those &#x27;worse is better&#x27; things in language design, I believe. It guarantees simplicity, traded off against extra verbosity. In fact, when it comes to the common and probably most valuable case of reading and understanding code written by others quickly, it is not even a tradeoff really, as <i>both</i> are good.<p>Whether or not that was one of the driving reasons, it certainly is a benefit in my opinion. The two examples given in the post of an inline require don&#x27;t demonstrate this well, as they&#x27;re both really simple. I&#x27;d say the benefit isn&#x27;t to stop things examples like that being written and replace them with two lines of code, which admittedly might sometimes be slightly cumbersome. It&#x27;s that it stops the long tail of much more complex&#x2F;unreadable statements being written.
评论 #29139153 未加载
评论 #29140926 未加载
Chyzwar超过 3 年前
Problem is bothed node.js implementation that leaves most of existing applications without migration path. Even today it is not possible to create full ESM application front or backend. It is worse than python 2 to 3.
评论 #29138987 未加载
评论 #29138482 未加载
评论 #29140978 未加载
eyelidlessness超过 3 年前
Here is why ESM is better for static analysis than CJS:<p><pre><code> module.exports = { get foo() { const otherModule = require(&#x27;equally-dynamic-cjs&#x27;) if (otherModule.enabled) { return any.dynamic.thing.at.all } }, get bar() { this.quux = &#x27;welp new export!&#x27; return 666 }, now: &#x27;you see it&#x27;, } setTimeout(() =&gt; { console.log(`now you don’t!`) delete module.exports.now }, Math.random() * 10000) if (Date.now() % 2 === 0) { module.exports = something.else.entirely } </code></pre> You can, of course, achieve this sort of dynamism with default exports. But default exports are only as tree-shakeable as CJS. Named exports are fully static and cannot be added or removed at runtime.<p>Edit: typed on my phone, apologies for any typos or formatting mistakes.
tbrock超过 3 年前
We recently went through this hell converting a NodeJS codebase to TypeScript. One reason many people willingly enter this hellscape is because we need ES modules for typescript.<p>I say “need” because Typescript wont ingest types from “required” files, you have to import them as modules.<p>So before we converted a single file to TS we has to audit all commonjs imports and exports to convert them to ES modules.<p>I agree wholeheartedly that the end result was a fools errand. I would have rather spent the time adding support for importing types via a require which for some reason returns any “any” today.
评论 #29138637 未加载
评论 #29138657 未加载
emersion超过 3 年前
I&#x27;m using ES modules for a webapp I maintain, and it&#x27;s just nice to be able to run it without any build step. Just fire off a local static HTTP server and you&#x27;re good to go. There&#x27;s an optional production build step which can be used if desirable.
评论 #29138973 未加载
junon超过 3 年前
This is a criticism of the tooling, not of the language feature.<p>This is like saying &quot;binding two pieces of wood together is terrible&quot; and using the fact that screwdrivers are poorly designed as your main argument.
Aeolun超过 3 年前
I kind of have to agree with the point about loading ESM in the browser.<p>I tried doing this with one of the new fangled frameworks and seeing my browser work through like 5000ish required files was quite comical.
评论 #29138391 未加载
评论 #29138970 未加载
bricss超过 3 年前
First you create problem with an article, then you fix it with your own magic tool, bravo!<p><a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;fix-esm" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;fix-esm</a>
评论 #29139183 未加载
评论 #29138496 未加载
评论 #29142644 未加载
jitl超过 3 年前
The things I dislike the most in software development is dogma, holy wars, and religious crusades about technology practices. I’m not sure to the extent that this happens in other ecosystems, but it seems to happen quite a bit in JavaScript circles. You can ignore these for the most part if you use boring tools and don’t chase the new frameworks-du-jour, but in the case of ESM versus CommonJS I am starting to feel the fire of this war in my dependency graph.<p>My solution in NodeJS programs for now is to use an `esbuild` -based require hook to transpile all the files we import or require into CommonJS on the fly. We need esbuild anyways to run Typescript code without a build step, and combined with basic mtime based caching, it’s fast enough that you really don’t notice extra build latency especially on a second run — much MUCH faster than a Babel require hook.<p>I plan to tune back into this issue once the average comment is more measured and thoughtful, and the ecosystem tooling for dealing with the migration has evolved more.
forty超过 3 年前
I have been doing nodejs backend development for the past 10 years and I have no idea why ES module are needed and who is using them. I assume this is a front end thing.<p>We are using typescript which is using &quot;import&quot; syntax, but as far as I know, it&#x27;s still transpiling to good old &quot;require&quot;.
评论 #29138995 未加载
评论 #29139316 未加载
dgb23超过 3 年前
In my opinion as a working web developer, ES modules are half-backed, deceptively simple, do not solve problems consistently and are not built on hard acquired wisdom from other languages.<p>1) JavaScript could have simply stolen an already good solution. For example namespaces (ex: Clojure&#x2F;Script, Typescript, even PHP to some degree) provide a powerful mechanism to modularize names - by disentangling them from loading code. They make it straight forward to avoid collisions and verbose (noisy) names. In Clojure namespaces are first class and meant to be globally unique. This implies long-term robustness.<p>2) Loading modules dynamically should be the _default_. The whole point of JavaScript is that it is a dynamic language. The caveats, hoops and traps that we have to sidestep to for example run a working, real REPL during development is astounding. If you want to be dynamic, go _all_ the way and understand what that means. Yes, it&#x27;s a tradeoff to be a dynamic language, but why take the worst of both worlds?<p>3) Like &#x27;async&#x2F;await&#x27;, &#x27;class&#x27; and many browser features such as IndexedDB it is neither designed from first principles nor fully based on past wisdom. Many things in the JS world smell of &quot;lowest common denominator&quot;. Way too much effort is focused on the convenience side of things and way too little on the leverage side.
amadeuspagel超过 3 年前
&gt; And then people go &quot;but you can use ESM in browsers without a build step!&quot;, apparently not realizing that that is an utterly useless feature because loading a full dependency tree over the network would be unreasonably and unavoidably slow - you&#x27;d need as many roundtrips as there are levels of depth in your dependency tree - and so you need some kind of build step anyway, eliminating this entire supposed benefit.<p>That&#x27;s not true with skypack, right?
评论 #29138604 未加载
评论 #29141973 未加载
somehnacct3757超过 3 年前
I keep thinking how QUIC &#x2F; HTTP&#x2F;3 would go nicely with ESM in the browser (via script tags with type=module) for simple sites.<p>A webmaster could totally avoid the complexity of learning a JS tool chain. Right now even 1000 lines of JS has you reaching for a bundler. It would make shipping a small html+css+js site again as simple as dragging files to your webserver.
评论 #29138849 未加载
评论 #29139203 未加载
cryptica超过 3 年前
It just sucks that development community decided to double down on bulky build tools instead of trying to optimize server environments to leverage advances like HTTP2 server push to optimistically serve dependencies without latency. It&#x27;s particularly strange when you consider how popular Node.js is as a server-side environment and how easy it would be to accomplish this since the server is able to interpret JavaScript natively to quickly figure out the client-side dependency tree.<p>My inner conspiracy theorist suspects that maybe the powers that be don&#x27;t want to allow plain JavaScript to extend its primacy over the web. The way things went makes no sense. Computing dependency trees on the server-side and using it to optimistically push scripts to the browser would have been be far simpler and less hacky than computing source maps, for example. Optimistically pushing server-side resources was supposed to be the whole point of HTTP2...
jokethrowaway超过 3 年前
ES Modules was what turned node.js into legacy for me, same as python 2&#x2F;3.<p>Plus transpilers are so slow, it&#x27;s embarrassing (albeit things are improving with tools written in rust).<p>As someone who&#x27;s been doing frontend for 20 years and node.js for 10 years, JS development has never been so crap like now.<p>After attending a conference talk about how the TC39 works, I understand why that&#x27;s the case. TC39 is basically a bunch of engineers from big tech companies who can afford to waste productivity to follow the whims of whatever the group decide. It&#x27;s completely detached from reality.<p>They operate on a full consensus basis, which means everyone needs to be onboard with the decisions - and if you want your changes to be approved in the future, you&#x27;d better play nice with the current change as well.<p>To be honest, I can&#x27;t wait until browsers get replaced with some native crossplatform toolkit or frameworks in other languages become popular so that we can finally leave JS alone.
评论 #29139013 未加载
评论 #29138798 未加载
lampe3超过 3 年前
Not sure it the author tried a new build tool like vite, esbuild and so on.<p>Working on large projects and having everything first loaded and then you can load it in the browser is a waste of time that every web developer has every day.<p>Some real world times FOR DEVELOPMENT: Storybook first load: 90 sec, Storybook after first load changes: 3 sec, Vue App first load: 63 sec, Vue app change after that: 5 sec, Vue App with Vite first load: 1sec, Vue App with Vite after that: the time it takes me to press command+tab to switch to the browser<p>Do we really have people that use unminfied unbundled esm in production? If Yes, please comment why?<p>I would also ask the author what about cyclic dependencies? ES Modules resolve them automatically. Something which in large code bases can happen.<p>Why do we still put it through babel? Because most of us don&#x27;t have the luxury of not supporting old browser... <a href="https:&#x2F;&#x2F;caniuse.com&#x2F;?search=modules" rel="nofollow">https:&#x2F;&#x2F;caniuse.com&#x2F;?search=modules</a> Even if the not supported browsers for our company is 1% it is still a big chunk of money in the end.<p>and this example: ``` app.use(&quot;&#x2F;users&quot;, require(&quot;.&#x2F;routers&#x2F;users&quot;)); ```<p>Really? this is &quot;good code&quot; having a require in the middle of a file?<p>Also funny: The author is annoyed that rollup did not support tree shaking in commonjs and then complains that people are wasting time on esm. Maybe the rollup team does not want to waste time on commonjs? Also then he points to a package which did not got any update in 3 years and would make the hole process he complains is to complex even more complex by introducing a new dependencies.<p>Sorry but the more I read that thing the more it sounds to me like a Junior Dev that does not want to learn new things and just likes to rant about things.
评论 #29139179 未加载
评论 #29140465 未加载
austincheney超过 3 年前
The reasoning presented is only valid if you are stuck holding a bunch of dependencies making use of old conventions. At that moment the complaints about the module approach become a very real concern.<p>That said the problem isn’t modules are all. It’s reliance on a forest of legacy nonsense. If you need a million NPM modules to write 9 lines of left pad these concerns are extremely important. If, on the other hand, your dependencies comprise a few TypeScript types there is nothing to worry about.<p>So it’s a legacy death spiral in the browser. Many developers need a bunch of legacy tools to compile things and bundles and build tools and all kinds of other extraneous bullshit. Part of that need is to compensate for tooling to handle modules that predates and is not compatible with the standard, which then reenforces not using the module standard.<p>When you get rid of that garbage it’s great. ES modules are fully supported in Node and the browser.
评论 #29138992 未加载
cookiengineer超过 3 年前
This thread and summary are written by someone who has no clue what they&#x27;re doing in ECMAScript; and who&#x27;s probably enjoying the fucked up mess that the babel ecosystem created. I&#x27;m not gonna dig into that, because reading any polyfill in babel&#x27;s ecosystem speaks for themselves on how messy, hacky, and actually not working-as-specified most parts are.<p>Instead I&#x27;m gonna try to go back to the topic.<p>I think that in practice these are my pain points in using ESM regularly without any build tool. I&#x27;m using ESM modules both in node.js and in the Web Browser via &lt;script type module&gt;:<p>- package.json&#x2F;exports &quot;hack&quot; works only in node.js and not in the Browser as there&#x27;s also no equivalent API available. This hack allows to namespace entry points for your library, so that you can use &quot;import foo from &#x27;bar&#x2F;qux&#x27;;&quot; without having to use &quot;..&#x2F;..&#x2F;..&#x2F;&quot; fatigued paths everywhere (that also might be different in the Browser compared to the nodejs entry points).<p>- &quot;export * from &#x27;...&#x27;;&quot; is kind of necessary all the time in &quot;index&quot; files, but has a different behaviour than expected because it will import variable names. So export * from something won&#x27;t work if the same variable name was exported by different files; and the last file usually wins (or it throws a SyntaxError, depending on the runtime).<p>- Something like &quot;import { * as something_else, named as foobar } from &#x27;foo&#x2F;bar&#x27;;&quot; would be the killer feature, as it would solve so many quirks of having to rename variables all the time. Default exports and named exports behave very differently in what they assign&#x2F;&quot;destruct&quot;, and this syntax would help fix those redundant imports everywhere.<p>- &quot;export already_imported_variable;&quot; - why the HECK is this not in the specification? Having to declare new variable names for exports makes the creation of &quot;index&quot; files so damn painful. This syntax could fix this.
评论 #29139473 未加载
eyelidlessness超过 3 年前
The reason ESM is better than CJS or any other JS module system is because of the export keyword. Any discussion focused on imports is relevant but missing the significance of ESM.
arh68超过 3 年前
Agreed. So much breakage for so little. If I were teaching JS today I don&#x27;t know if ESM is worth covering while CJS works at least as well. Maybe next year.
tolmasky超过 3 年前
The “it works without a tool chain” is in fact a ridiculous impractical hypothetical that no one should actually attempt, and yet it continues to make this spec more complicated and unwieldy. For example, to address the obvious performance problem of dealing with loading dependencies, the “&lt;link del=modulepreload&gt;” tag was added, which you’re supposed to include for each individual dependency in your html to let it know to start fetching it ahead of time. So we’ve literally gone full circle and arrived right back to where we started with a script tag for every JS file being replaced with a link tag for every JS file. “But you don’t have to manually do that! Your build tools can just insert the 100 link tags in your HTML file!” I thought all this was to avoid a JS tool chain! If I’m running a build tool I’ll just have it generate one concatenated and minified artifact that performs way better, not this mess! Here’s the documentation if you’re interested in this hilarious feature: <a href="https:&#x2F;&#x2F;developers.google.com&#x2F;web&#x2F;updates&#x2F;2017&#x2F;12&#x2F;modulepreload#but_what_about_modules_dependencies" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;web&#x2F;updates&#x2F;2017&#x2F;12&#x2F;moduleprel...</a><p>Not to mention the security aspects: there is no subresource integrity for imports, so it’s less secure than bundling or using a script tag with CDNs.<p>The point about it being a new syntax is also very valid. Everything import patterns do is <i>almost</i> identical to destructuring, so we should have just extended that feature instead, especially because I do wish destructuring could do those things. For example, if destructuring had an “everything” pattern to complement the “rest” pattern:<p><pre><code> const { x, …rest, *original } = something(); </code></pre> Where “original” now just contains a reference to the actual returned object, instead of having to break that pattern up into two declarations since the moment destructuring takes place the original object becomes inaccessible. This would have of course given us the “import * as” ability, but is again a feature I regularly find myself wanting everywhere. Not to mention this makes writing code transformations even harder as JavaScript&#x27;s huge syntax keeps growing and requiring tons of special cases for almost identical statements.<p>The semantics of imports are also very confusing to beginners, as they implement yet another unique form of hoisting. It is <i>so weird</i> that despite being allowed anywhere in your code, they <i>run</i> first. Notice I didn’t say they <i>fetch</i> first, they <i>run</i> first. So for example, the following code is broken:<p><pre><code> process.env.S3_LOCATION = “https:&#x2F;&#x2F;…”; &#x2F;&#x2F; The below library expects this as an environment variable. import download from “s3-download”; </code></pre> Oops! Your env variable gets set <i>after every line of code in the import chain of s3-download runs!</i> So bizarrely, the solution is to put the first line <i>in its own import</i>, and now it <i>will</i> run first<p><pre><code> import unused from “.&#x2F;set-env-variable.js” import download from “s3-download” </code></pre> If the rule is that imports <i>must</i> run before any code in the file, then why not restrict the statement to only being at the top of the file? What is the purpose of allowing you to put all your imports at the bottom? Just to make JavaScript even more confusing to people? Imagine if “use strict” could appear <i>anywhere</i> in the file, even 1000 lines in, but then still affected the whole file. It was already the case that people found function hoisting, &quot;var undefined&quot; hoisting, and the temporal dead zone of let&#x2F;const (3 different kinds of subtly different hoists) to be confusing in a language that prides itself for being able to be read &quot;top to bottom&quot;, why add a <i>fourth</i> form of hoisting?<p>Anyways, the list of problems actually continues, but there is widespread acceptance that this feature would not have been accepted in its current form if introduced today. But for some reason everyone just takes a “but it’s what we got” position and then continues piling more junk on top of it making it even worse.
incrudible超过 3 年前
<i>&quot;And then people go &quot;but you can use ESM in browsers without a build step!&quot;, apparently not realizing that that is an utterly useless feature because loading a full dependency tree over the network would be unreasonably and unavoidably slow - you&#x27;d need as many roundtrips as there are levels of depth in your dependency tree - and so you need some kind of build step anyway, eliminating this entire supposed benefit.</i><p>That build step is <i>ideally</i> performed by something like rollup or esbuild, which means I use import&#x2F;export anyway. If you still use Babel, I feel bad for you son, I&#x27;ve got 99 problems but Babel ain&#x27;t one. I don&#x27;t care if the old stuff is not supported, simply deleting 98% of the code in the JS ecosystem would be a step forward. Perhaps that&#x27;s a minority view, but none of these arguments fly with me.
aurelianito超过 3 年前
Both CommonJS and ES6 modules suck. The way things should have been is requirejs. Modules are defined and loading using an API instead of having reserved words. It&#x27;s really sad what happened to modules in JavaScript.
terracottage超过 3 年前
The worst part is default imports and the linting nazis who want you to use them.<p>1 file per thing is midwit code organization strategy for people with no actual sense for it.
rado超过 3 年前
HTTP&#x2F;2 uses a single connection for all modules, no?
评论 #29143149 未加载
aliswe超过 3 年前
i have sympathy for your projects that will need maintenance. but i am making the observation that you&#x27;re starting to get old - you&#x27;re being quite bitter over something which is clearly bigger than all of us.<p>on a personal note, im making a cms with es modules and couldnt be happier.
lucideer超过 3 年前
TL;DR:<p>Breaking backwards compatibility is always painful but there&#x27;s not one actual criticism of ES Modules as a spec here other than its incompatibility with CommonJS
评论 #29138638 未加载
评论 #29138375 未加载
评论 #29138686 未加载
评论 #29138386 未加载
评论 #29138509 未加载
throwaway2077超过 3 年前
question:<p><pre><code> &#x2F;&#x2F; ... if (condition) { const x = require(&#x27;..&#x2F;..&#x2F;..&#x2F;hugeFuckingLibraryThatTakesSeveralSecondsToLoadUponColdStart&#x27;) &#x2F;&#x2F; do something with x } &#x2F;&#x2F; ... </code></pre> assume I don&#x27;t give a fuck about nerd bullshit and I just want the code to be simple and the program to run fast (which it does when !condition because it doesn&#x27;t need to load hugeFuckingLibrary), can I replicate this behavior with ESM?
评论 #29139043 未加载
评论 #29141931 未加载
axismundi超过 3 年前
Don&#x27;t bundle. The only reason for bundling is too many requests to the server. Use HTTP&#x2F;2 instead.
评论 #29138734 未加载
评论 #29138817 未加载
评论 #29138771 未加载
vbg超过 3 年前
Rather a negative outlook.
api超过 3 年前
It’s puzzling to me why there isn’t more effort on developing front end Go or Rust frameworks that compile to JS or WASM. It would be a chance to work in a real language instead of this trash.