ES Modules
See original GitHub issueIt is not possible to use this package in an ES module because of the use of __dirname
in the code: https://github.com/mashpie/i18n-node/blob/v0.15.0/i18n.js#L125. What it be possible to use another approach?
Or export a file that can be used by a ES module project
Issue Analytics
- State:
- Created 9 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
ES modules: A cartoon deep-dive - Mozilla Hacks - the Web ...
Modules give you a better way to organize these variables and functions. With modules, you group the variables and functions that make sense...
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
ECMAScript modules are the official standard format to package JavaScript code for reuse. Modules are defined using a variety of import and export...
Read more >ES Modules | Dev Cheatsheets - Michael Currin
As of ES6 (ES2015), JavaScript supports a native module format called ES Modules, or ECMAScript Modules. This is modern way to do modules...
Read more >CommonJS vs ES Modules in Node.js - A Detailed Comparison
ES Modules are a new module system developed by Google which allows for greater modularity and reuse across different programming languages.
Read more >CommonJS vs. ES modules in Node.js - LogRocket Blog
The ES module format was created to standardize the JavaScript module system. It has become the standard format for encapsulating JavaScript ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
__dirname
is CJS only whileimport.meta.url
is ESM only. So i18n would need some transpiler to support both package types… eventually there’ll be major release for ESM only dropping CJS support as proposed by https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99cFor now you might try with explicitly setting
directory
instead of falling back to defaults, ie.:now you get back full control about your locales directory setting
do you have a reproduction repo? I just tried both https://github.com/mashpie/i18n-esm-cjs-example and don’t get any errors