5/6/2023 0 Comments Unpkg moment typesMake small reproductions of different sections of the library and experiment with tree shaking Research about features in different es targets Find out what typescript features require tslib even when targeting es6+ (for example - decorators) It will also allow to import directly from the root (side effect free). This will allow bundlers … to remove unnecessary code, allowing sites to ship less codes to get faster load. If you’d like me to post a github issue, just let me knowĮdit: hmm, this form limits me to two real links, sorry but you’ll have to copy-paste if you want to follow themĪdd ECMAScript Modules support to our new build system. Thanks for reading, and of course it goes without saying, i’m no authority on how es modules work - we’re all learning and developing these new ideas together, so if i seem misguided or there’s a different way to think about or avoid these problems, i’d love to discuss it, so please speak up! (workaround-b) unpkg has a ?module feature which rewrites bare specifiers (see my reply post for more details) (workaround-a) we can use es-module-shims ( ) to shim the import maps see the codepen demo ( ) (future solution) we’ll use import-maps ( ) to remap the bare-specifiers ![]() There are some bare specifiers in babylon referencing tslib, at least for the decorator function, it looks to meīare specifiers are reserved ( ) for builtin modules, however in the future, we’ll be able to rewrite them via import-maps The following error is thrown: Uncaught TypeError: Failed to resolve module specifier "tslib". js extensions to all module references in babylon’s typescript sourcecode (or otherwise. ![]() User workaround: rely on unpkg’s rewriting hack for now js) – and typescript is totally relaxed about it, and will emit the desired extension, and so typescript is smart enough to know that abstractScene.js is the same as abstractScene.ts mjsĪt first in my own projects, i found this requirement confusing, because typescript doesn’t have a compiler option to emit a particular extension in the module specifiers - however as a solution, i found that typescript seems to be designed, for this purpose, to ignore file extensions in your typescript sourcecode – such that you can tweak all of your module references (in your ts source) to, for example, export * from "./abstractScene.js" (adding the. The lack of extensions causes loading babylon via jsdelivr to fail (which doesn’t have the ?module hack feature) - import * as babylon from that there are ongoing debates ( ) on whether the future of es modules on the web should be expressed as. js file for any file requested without an extension (eg, “index” becomes “index.js” thanks to the unpkg server, but this is non-standard behavior that should not be relied on) (other npm-cdn’s, like jsdelivr, don’t seem to offer this helpful hack) Omitting the extensions is not valid, however in our example case, unpkg goes one extra step to counteract the problem: it will serve the. When we look at ( ) we can see that the emitted module specifiers do not have extensions Module specifiers are lacking the required extensions So given the following code to load babylon via unpkg (which seems to be an awesome hipster replacement for npm, from the future!) (here’s this example on codepen) import * as babylon from = "done!" ![]() I’m really excited since all the cool browsers support proper es-modules, so i’ve been upgrading my typescript libraries to emit es-modules and umd-modules, and in new projects, i’ve been experimenting with having no build-step at all. Hello friends! i’m experimenting with the future, today!
0 Comments
Leave a Reply. |