home.social

#commonjs — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #commonjs, aggregated by home.social.

fetched live
  1. It's almost 2026 and we are still dealing with #commonjs vs #ESM issues in #nodejs. 2026 will be the last year that Keyv (keyv.org ) attempts to support commonjs with v6 due out this year. In 2027 we will move to ESM only with v7. It is just too painful to support commonjs compatibility.

    This will also mean that `cache-manager`, `cacheable`, etc... will all move to ESM only in 2027. That is a large amount of caching usage across projects.

    #typescript #javascript

  2. It's almost 2026 and we are still dealing with #commonjs vs #ESM issues in #nodejs. 2026 will be the last year that Keyv (keyv.org ) attempts to support commonjs with v6 due out this year. In 2027 we will move to ESM only with v7. It is just too painful to support commonjs compatibility.

    This will also mean that `cache-manager`, `cacheable`, etc... will all move to ESM only in 2027. That is a large amount of caching usage across projects.

    #typescript #javascript

  3. Пока, dual packaging: в каком формате публиковать npm-библиотеки

    Уже 10 лет в JS-экосистеме воюют два формата модулей: CommonJS и ES Modules. Чтобы и получить плюшки ESM, и не распугать пользователей, npm-пакеты часто используют dual packaging: собирают код в оба формата. Это решает одну проблему, но создает несколько новых. Сегодня расскажу Какие проблемы пришли к dual packaging, и не пора ли от него отказаться. В какой формат паковать npm-библиотеки в 2025 году. Статься будет полезна и для опенсорса, и для внутренних библиотек, и для простых разработчиков (хотя бы чтобы понимать, откуда у вас в node_modules 2 Гб).

    habr.com/ru/articles/933754/

    #npm #esm #nodejs #commonjs #javascript #opensourse

  4. [Перевод] Публикация пакета npm с ESM и TypeScript

    За последние 2 года поддержка ESM в TypeScript, Node.js и браузерах сильно улучшилась. В этой статье я объясню мою современную настройку, которая является относительно простой по сравнению с тем, что нам приходилось делать раньше: она предназначена для пакетов, которые могут пренебречь обратной совместимостью. Настройка хорошо работает для меня некоторое время — начиная с TS 4.7 (24.05.2022) помогает то, что Node.js теперь поддерживает require(esm) — запрос библиотек ESM из модулей CommonJS я использую только tsc , но упоминаю поддержку других инструментов в разделе "Компиляция TS с помощью других инструментов" Обратная связь приветствуется: что вы делаете по-другому? Что может быть улучшено? Пример пакета: в @rauschma/helpers используется настройка, описываемая в этой статье.

    habr.com/ru/companies/timeweb/

    #timeweb_статьи_перевод #javascript #typescript #ts #npm_package #npm_registry #npm #esm #commonjs #реестр_npm #пакет_npm

  5. #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:​

  6. #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:​

  7. @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: youtube.com/watch?v=SIows5N4BA

    😆

  8. @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: youtube.com/watch?v=SIows5N4BA

    😆

  9. Want to know why #CommonJS was a mistake?
    One phrase. Conditional #module #exports.

    if (condition) {
    module.exports = foo
    } else {
    module.exports = bar
    }

    #javaScript #nodejs #cjs #js #webDev #esm #modules

  10. Want to know why #CommonJS was a mistake?
    One phrase. Conditional #module #exports.

    if (condition) {
    module.exports = foo
    } else {
    module.exports = bar
    }

    #javaScript #nodejs #cjs #js #webDev #esm #modules

  11. Управление зависимостями в Javascript заходит на новый виток? Работа с ES модулями без сборщиков

    Изначально эта статья задумывалась, как рассказ о различиях и назначении полей dependencies , devDependencies и peerDependencies в package.json . Эту тему выбрали ребята в моем телеграм-канале , кстати подписывайтесь, если еще не. Однако, когда я посмотрел количество контента на эту тему, то понял, что его достаточно даже в русском сегменте. При этом я прочитал одну статью , которая показалась мне очень хорошей, а также там были мысли на тему будущего управления зависимостями. В итоге, я решил кратко пересказать вышеупомянутую статью, чтобы лучше самому усвоить тему, а также набросать проект по управлению зависимостями прямо на клиенте, через ES Modules. Так что вы можете прочитать либо оригинальную и полную статью у автора, либо сокращенную версию в первой половине этой статьи. А разбор работы ESM будет во второй половине .

    habr.com/ru/articles/825424/

    #npm #yarn #pnpm #javascript #node #esm #commonjs #dependency_management #package_manager

  12. 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

  13. 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

  14. > 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.

    borischerny.com/javascript,/ty

    #javaScript #nodeJS #esModules #webdev #web #typescript #esm #cjs #commonjs #package #npm

  15. > 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.

    borischerny.com/javascript,/ty

    #javaScript #nodeJS #esModules #webdev #web #typescript #esm #cjs #commonjs #package #npm

  16. The only thing I miss from #CommonJS imports is ability to have optional dependencies.

    ```js
    let dep = null;
    try {
    dep = require('opt-dep')
    } catch {}
    ```

    The closest thing in #ESM you can get is import via top-level await, but it's not always available and causes all sorts of funky things.

  17. 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

    hexagon.56k.guru/posts/dual-mo

  18. 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

    hexagon.56k.guru/posts/dual-mo

  19. A new post on how to create a React components library, although focusing on the aspects of publishing dual libraries (CJS+ESM) with types: blog.coderspirit.xyz/blog/2023

    #JavaScript #TypeScript #ESM #CommonJS

  20. A new post on how to create a React components library, although focusing on the aspects of publishing dual libraries (CJS+ESM) with types: blog.coderspirit.xyz/blog/2023

    #JavaScript #TypeScript #ESM #CommonJS

  21. As supporting both and can be wrongly done in a thousand ways, I published why and how we achieved that on fast-check.

    This article is a follow-up of issues reported via 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 .

    Link to the article: fast-check.dev/blog/2023/09/04

  22. 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: fast-check.dev/blog/2023/09/04

  23. @GabeMoralesVR I am a complete newbie of Javascript. Modules have created a lot of difficulties as I do not yet understand how they work and the documentation is confusing as some Emscripten exemples refer to #CommonJS whereas browsers prefer #ES6.

  24. @GabeMoralesVR I am a complete newbie of Javascript. Modules have created a lot of difficulties as I do not yet understand how they work and the documentation is confusing as some Emscripten exemples refer to #CommonJS whereas browsers prefer #ES6.

  25. In 2009, #CommonJS was exactly what #JavaScript needed. The group took a tough problem and forced through a solution that continues to be used millions of times a day.

    But with #ESM as the standard and the focus shifting towards cloud primitives — the edge, browsers, and #serverless compute — and CommonJS simply doesn’t cut it. ESM is a better solution for developers, as they can write browser-compliant code — and for users who get a better end experience.

    deno.com/blog/commonjs-is-hurt

    #webDev

  26. In 2009, #CommonJS was exactly what #JavaScript needed. The group took a tough problem and forced through a solution that continues to be used millions of times a day.

    But with #ESM as the standard and the focus shifting towards cloud primitives — the edge, browsers, and #serverless compute — and CommonJS simply doesn’t cut it. ESM is a better solution for developers, as they can write browser-compliant code — and for users who get a better end experience.

    deno.com/blog/commonjs-is-hurt

    #webDev

  27. Should I transpile this code? I really want to use Typescript and new JS features?

    Do I want to support #ESModules and #CommonJS? Should I bundle this code? What about #Node vs. #Deno Browser vs. compatibility?

  28. Should I transpile this code? I really want to use Typescript and new JS features?

    Do I want to support #ESModules and #CommonJS? Should I bundle this code? What about #Node vs. #Deno Browser vs. compatibility?

  29. I am creating a library using #typescript I would like to generate using the same codebase a valid #deno import, an #javascript #ESM module and #CommonJS module for maximum compatibility. Does anyone have a magic tsconfig configuration in the best case, or any idea about an easy solution to achieve this?

  30. I am creating a library using #typescript I would like to generate using the same codebase a valid #deno import, an #javascript #ESM module and #CommonJS module for maximum compatibility. Does anyone have a magic tsconfig configuration in the best case, or any idea about an easy solution to achieve this?

  31. CW: programming

    Today, #nodejs package hell drove me crazy. #commonjs and #esm bundling with only #esbuild seems to be impossible today; at least I didn't manage to get a configuration that supports
    - browser environment (when installled in an app, for example with #vitejs)
    - node environment (for services in node docker containers)
    - bin script support

    Especiallly the generated CommonJS of esbuild seems to be strange and lead to a lot of incompatibilites.

  32. 1/ Happy to see that ESM modules have become popular in current code bases (*):
    – Mostly ESM: 68%
    – Mostly CommonJS: 17%
    – A mix: 12%
    – (No answer: 3%)

    In my own (relatively simple) ESM-based Node.js projects I was delighted that I usually couldn’t even tell if a dependency was ESM or CommonJS.

    (*) fosstodon.org/@rauschma/109824
    #JavaScript #CommonJS #ESM #NodeJS

  33. Anyone know something about ESM, CommonJS, Typescript and how they interact?

    Stuck on a problem, posted on Stack overflow:

    stackoverflow.com/questions/75

    #node #typescript #esm #commonjs