35 Matching Annotations
- Nov 2022
-
stackoverflow.com stackoverflow.com
-
You're likely not using "type": "module" in your package.json, so import statements don't work in svelte.config.js. You have three ways to fix this: Use require() instead (also see https://github.com/sveltejs/language-tools/blob/master/docs/preprocessors/in-general.md#generic-setup) Rename svelte.config.js to svelte.config.mjs Set "type": "module" in your package.json (may break other scripts)
-
- May 2021
-
github.com github.com
-
It's a chicken-and-egg-like problem: If we use module: 'commonjs', then if any TS files import ES Modules (indirectly in their dependency graph), then Node throws an error because CommonJS modules can not import ES Modules.
-
-
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.
-
- Nov 2020
-
github.com github.com
-
Microbundle also outputs a modern bundle specially designed to work in all modern browsers. This bundle preserves most modern JS features when compiling your code, but ensures the result runs in 90% of web browsers without needing to be transpiled. Specifically, it uses preset-modules to target the set of browsers that support <script type="module"> - that allows syntax like async/await, tagged templates, arrow functions, destructured and rest parameters, etc. The result is generally smaller and faster to execute than the esm bundle
-
-
-
If I use import { createEventDispatcher } from 'svelte/internal'; instead of import { createEventDispatcher } from 'svelte'; then it seems to work because it's loading from the same module.
-
-
-
is not required to point to "svelte": "src/main.html" if you're bundling for es, "module": "dist/main.mjs" would suffice. I mean, it's a good thing to provide a single file, not the whole sources again.
Tags
Annotators
URL
-
-
github.com github.com
-
But seriously, give snowpack a read to understand the benefits of leaning on standard esm imports, allowing you to avoid a bundling process entirely.
-
I don't need to support non-esm browsers for most projects and I really like the idea of a super light build process. By removing the complexity of configuration and the overhead of bundling, svelvet makes the development process an optimal experience for myself and hopefully others
-
-
www.snowpack.dev www.snowpack.devSnowpack2
-
It replaces heavier, more complex bundlers like webpack or Parcel in your development workflow.
-
-
- 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
-
-
www.npmjs.com www.npmjs.com
-
it’s transferred to ES Modules and CommonJS format.
Tags
Annotators
URL
-
-
deno.land deno.land
-
Uses "ES Modules" and does not support require(). Third party modules are imported via URLs:
-
-
github.com github.com
-
import page from "//unpkg.com/page/page.mjs";
-
Or with modules, in modern browsers
-
-
justintimecoder.com justintimecoder.com
-
In the brave new world of ES6 + JavaScript, we have a syntax that allows us to declare the dependencies of one file to other files in our project i.e the import keyword, as well as the ability to declare the functions, classes, and variables that other files may import i.e the export keyword.
-
-
developer.mozilla.org developer.mozilla.org
-
The defer attribute has no effect on module scripts — they defer by default.
-
- Sep 2020
-
medium.com medium.com
-
Because ESM is syntax, it’s very easy to statically analyze.
-
-
stackoverflow.com stackoverflow.com
-
// convert CommonJS modules to ES modules
-
-
stackoverflow.com stackoverflow.com
-
Why do I need a global variable? Is the global requirement from ES6 modules (I'd have thought modules would be in a functional scope) or rollup?
-
-
engineering.mixmax.com engineering.mixmax.com
-
Rollup builds atop Browserify and Webpack's lineage to make it possible to easily consume those packages, while looking to the future of JS modules.
-
Rollup is a tool that lets you write your application using ES6 modules, even though you can't publish those modules directly to your users, because native support is only just starting to land in browsers. Rollup compiles your modules into a format that all browsers _do_ understand—a single script file—by, essentially, concatenating files together (while reordering and renaming declarations to preserve scope).
-
-
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".
-
ES modules let you freely and seamlessly combine the most useful individual functions from your favorite libraries
-
-
bl.ocks.org bl.ocks.org
-
This is a demonstration of building a custom D3 4.0 bundle using ES2015 modules and Rollup. Custom bundles can be optimized to contain only the code you need. This example exposes just three fields on the d3 object: d3.event, d3.select and d3.selectAll. The minified and gzipped bundle is only 3,691 bytes, a savings of 93% over the default build!
-
-
twitter.com twitter.com
-
Why I’m excited about ES6 modules: a custom build of D3 4.0 in 3,610 gzipped bytes. (93% smaller!)
-
-
-
Now only the defined subpath in "exports" can be imported by a consumer:
-
"exports": { ".": "./main.js", "./submodule": "./src/submodule.js" }
Tags
Annotators
URL
-
-
-
type: "javascript/auto
-
-
exploringjs.com exploringjs.com
-
The module specifier is always fixed. That is, you can’t change what you import depending on a condition. And you can’t assemble a specifier dynamically.
-
-
developer.mozilla.org developer.mozilla.org
-
It is good for clarity, i.e. it makes it clear which files are modules, and which are regular JavaScript.
-
-
stackoverflow.com stackoverflow.com
-
Understand that an "external module" is a file containing an import or export statement, that an "ambient module declaration" reads declare module "m" {} (note the quotes), and reread the error message.
-
- Dec 2019
-
2ality.com 2ality.com
-
ES modules enable tree-shaking (which, in general, is impossible with CommonJS modules).
-