14 Matching Annotations
- May 2021
-
blog.sindresorhus.com blog.sindresorhus.com
-
CommonJS has served us well for many years, but ESM comes with many benefits, like language-level syntax, browser support, defaults to strict mode, async loading, top-level await, improved static analysis & tree-shaking, and more.
-
- Oct 2020
-
github.com github.com
-
Doing so also means adding empty import statements to guarantee correct order of evaluation of modules (in ES modules, evaluation order is determined statically by the order of import declarations, whereas in CommonJS – and environments that simulate CommonJS by shipping a module loader, i.e. Browserify and Webpack – evaluation order is determined at runtime by the order in which require statements are encountered).
Here: dynamic loading (libraries/functions) meaning: at run time
-
Replaced nested `require` statements with `import` declarations for the sake of a leaner bundle. This entails adding empty imports to three files to guarantee correct ordering – see https://github.com/styled-components/styled-components/pull/100
-
-
github.com github.com
-
browserify is a tool for compiling node-flavored commonjs modules for the browser.
-
- Sep 2020
-
medium.com medium.com
-
Unfortunately, many third party libraries, even though they are written in ESM, are published to npm as CJS modules, so we still need to concatenate them.
-
-
stackoverflow.com stackoverflow.com
-
// convert CommonJS modules to ES modules
-
-
github.com github.com
-
using modulesOnly behaves exactly as expected when it warns you that the listed npm libraries do not use the ES6 format and are in fact ignored. This option is meant as a way to determine if you still have commonjs libraries in your dependencies that require special treatment via rollup-plugin-commonjs. Your code will probably not work since the listed dependencies will be missing. You should remove modulesOnly and instead add rollup-plugin-commonjs.
-
-
rollupjs.org rollupjs.orgRollup2
-
In other words for those tools, you cannot create a package interface where const lib = require("your-lib") yields the same as import lib from "your-lib". With named export mode however, const {lib} = require("your-lib") will be equivalent to import {lib} from "your-lib".
-
To make sure your ES modules are immediately usable by tools that work with CommonJS such as Node.js and webpack, you can use Rollup to compile to UMD or CommonJS format, and then point to that compiled version with the main property in your package.json file.
-
-
engineering.mixmax.com engineering.mixmax.com
-
If you've followed React's guide, you've installed react from npm. You can teach Rollup how to find this package within your project's node_modules directory using the rollup-plugin-node-resolve plugin. Since React exports a CommonJS module, you'll also need to convert that into an ES6 module using the rollup-plugin-commonjs plugin.
-
-
github.com github.com
-
Since most CommonJS packages you are importing are probably dependencies in node_modules, you may need to use @rollup/plugin-node-resolve:
-
- Dec 2019
-
stackoverflow.com stackoverflow.com
-
commonJS (using exports.default =)
-
-
2ality.com 2ality.com
-
ES modules enable tree-shaking (which, in general, is impossible with CommonJS modules).
-
- Sep 2018
-
javascript.ruanyifeng.com javascript.ruanyifeng.com
-
module.exports属性表示当前模块对外输出的接口,其他文件加载该模块,实际上就是读取module.exports变量。
也就是说:
require
获得的是module.export
对象;export === modue.export
指向同一块内存;export
是一个快捷方式,覆盖就没有意义;module.export
可以覆盖,这取决与需要暴露什么对象或方法;覆盖后export
无效,因为 第 1 条;
-