Building the Bridge: Running JavaScript Modules From Dart, by (not found on Mastodon or Bluesky):
Building the Bridge: Running JavaScript Modules From Dart, by (not found on Mastodon or Bluesky):
[Перевод] Публикация пакета npm с ESM и TypeScript
За последние 2 года поддержка ESM в TypeScript, Node.js и браузерах сильно улучшилась. В этой статье я объясню мою современную настройку, которая является относительно простой по сравнению с тем, что нам приходилось делать раньше: она предназначена для пакетов, которые могут пренебречь обратной совместимостью. Настройка хорошо работает для меня некоторое время — начиная с TS 4.7 (24.05.2022) помогает то, что Node.js теперь поддерживает require(esm) — запрос библиотек ESM из модулей CommonJS я использую только tsc , но упоминаю поддержку других инструментов в разделе "Компиляция TS с помощью других инструментов" Обратная связь приветствуется: что вы делаете по-другому? Что может быть улучшено? Пример пакета: в @rauschma/helpers используется настройка, описываемая в этой статье.
https://habr.com/ru/companies/timeweb/articles/884516/
#timeweb_статьи_перевод #javascript #typescript #ts #npm_package #npm_registry #npm #esm #commonjs #реестр_npm #пакет_npm
#Javascript seems like such a fucking mess when the way you're importing libraries can somehow vary for wtv reason??? I also can never quite comprehend wth's an #ESM or #CommonJS :frierencrying:
@tolmasky the amount of times I had to learn what is #CommonJS and what is #ESM to then forget it and get bitten again when I come to #JS is bleak in comparison, I'm sure, but it made me make a video (mostly for myself) to later watch: https://www.youtube.com/watch?v=SIows5N4BAY
😆
Spent tonight learning #11ty and working on https://www.jameskerrane.com
- Updated to @eleventy v3.0.0! 🥳
- Refactored project files to switch from #CommonJS syntax to the newly supported and standardized #ESM modules
- Streamlined how the site handles images
- Started work on moving away from #nunjucks for templates to liquid or something else
- Renamed the repository
The nature of all of these changes is that the site doesn't look different, but the developer experience is cooler! 🚀
It's 2024; #JavaScript #libraries should be shipping #ESModules *only*
#webDev #frontend #js #modules #esm #commonjs #modularity #nodejs #deno
Управление зависимостями в Javascript заходит на новый виток? Работа с ES модулями без сборщиков
Изначально эта статья задумывалась, как рассказ о различиях и назначении полей dependencies , devDependencies и peerDependencies в package.json . Эту тему выбрали ребята в моем телеграм-канале , кстати подписывайтесь, если еще не. Однако, когда я посмотрел количество контента на эту тему, то понял, что его достаточно даже в русском сегменте. При этом я прочитал одну статью , которая показалась мне очень хорошей, а также там были мысли на тему будущего управления зависимостями. В итоге, я решил кратко пересказать вышеупомянутую статью, чтобы лучше самому усвоить тему, а также набросать проект по управлению зависимостями прямо на клиенте, через ES Modules. Так что вы можете прочитать либо оригинальную и полную статью у автора, либо сокращенную версию в первой половине этой статьи. А разбор работы ESM будет во второй половине .
https://habr.com/ru/articles/825424/
#npm #yarn #pnpm #javascript #node #esm #commonjs #dependency_management #package_manager
Is it wrong if I'm kind of enjoying the drama about #ljharb?
Burn tc39 down! Make the web anew!
The only standard is death comes to everything!
#webDev #javaScript #tc39 #nodejs #esm #esmodules #commonjs #cjs #modules
> enough libraries use ES Modules that for many projects you need to either use ES Modules, or figure out how to interoperate ES Modules with your CommonJS code. At the same time, enough code still uses CommonJS that you often need to figure out how to include that legacy code in your otherwise-ES Module project.
https://borischerny.com/javascript,/typescript/2024/06/19/ES-Modules-Are-A-Mess.html
#javaScript #nodeJS #esModules #webdev #web #typescript #esm #cjs #commonjs #package #npm
Mixed Imports: Loading JSON Directly in TypeScript and ES Modules https://link.medium.com/GU8QNAZOeKb
> Support for require()ing ESM graphs is now exposed by default in Node.js 22
https://openjsf.org/blog/nodejs-22-available
#nodejs #webDev #javaScript #esm #esmodules #commonJS #js #web #node
Javascript / NodeJS
Did you ever get an annoying error message while trying to access __dirname in a #javascript module running #node ?
__dirname and __filename were global variables in the old #CommonJS so they never worked when using proper modern js modules.
You had to write some ugly extra helper code to get this functionality.
Well, it's now fixed! As of node version 20.11.0 you can use
import.meta.filename
import.meta.dirname
https://www.sonarsource.com/blog/dirname-node-js-es-modules/
Progress report, March 30, 2024.
I tried #CommonJS packaging, but it turned out to be quite challenging, so I decided to support #ESM only.
I got #Fedify packaged into npm using #dnt, but it hasn't been published to npm yet.
I've made the entire unit test pass in Node.js now.
It was pre-released to JSR as version 0.5.0-dev.86+31d077e4, and you can test it out: https://jsr.io/@fedify/fedify@0.5.0-dev.86+31d077e4
https://github.com/dahlia/fedify/discussions/24#discussioncomment-8958020
[Action Required] AWS Lambda end of support for Node.js 16
-> Upgrading Node.js Lambdas above v18 or v20
Learn to create libraries compatible with both ESM and CommonJS, as well as different runtimes like Node.js, Deno, and browsers.
#deno #bun #node #esm #commonjs #javascript
https://hexagon.56k.guru/posts/dual-mode-cross-runtime-packages/
A new post on how to create a React components library, although focusing on the aspects of publishing dual libraries (CJS+ESM) with types: https://blog.coderspirit.xyz/blog/2023/09/15/create-a-react-component-lib/
https://gist.github.com/lil5/f2163f18ba67ae51a7f67a329294ca4b
I finally managed to get #NodeJS working with #Typescript without using #CommonJS
This was the only resource that actually worked: https://www.youtube.com/watch?v=H91aqUHn8sE&pp=ygUabm9kZW5leHQgbW9kdWxlIHJlc29sdXRpb24%3D
As supporting both #CommonJS and #ESModules can be wrongly done in a thousand ways, I published why and how we achieved that on fast-check. #JavaScript #opensource
This article is a follow-up of issues reported via #publint from @bluwy and fixed thank to @AndaristRake. As making the package right was not an easy game at first glance, I thought that a how-we-do article could help other #maintainers.
Link to the article: https://fast-check.dev/blog/2023/09/04/dual-packages-or-supporting-both-cjs-and-esm/