I hereby claim:
- I am geoffreybooth on github.
- I am geoffreybooth (https://keybase.io/geoffreybooth) on keybase.
- I have a public key ASCC0jgjIYKHBuZte1eKYWlMkqws78Yqm1NEZooCeAWrZAo
To claim this, I am signing this object:
# RollbackAttributes should also rollback relationships | |
# Based on http://stackoverflow.com/a/27184207/223225 and https://github.com/emberjs/rfcs/pull/21#issuecomment-135134132 | |
DS.Model.reopen | |
rollbackAttributes: -> | |
@_super() | |
@rollbackRelationships() | |
cacheOriginalRelations: -> |
Error.stackTraceLimit = Infinity; | |
var { | |
Scope | |
} = require("./scope"); | |
var { | |
isUnassignable, | |
JS_FORBIDDEN | |
} = require("./lexer"); |
test "Ensure that the closure wrapper preserves local variables.", -> | |
obj = {} | |
for method in ['one', 'two', 'three'] then do (method) -> | |
obj[method] = -> | |
"I'm " + method | |
ok obj.one() is "I'm one" | |
ok obj.two() is "I'm two" |
I hereby claim:
To claim this, I am signing this object:
These are the packages in the public NPM registry as of 2018-10-22 that have a value defined for the "module"
field in their package.json
files.
Dependents | Name | "module" value |
---|---|---|
16286 | should | ./es6/should.js |
15472 | sinon | ./pkg/sinon-esm.js |
1641 | redux | es/redux.js |
1579 | rollup | dist/rollup.es.js |
I did some research into the package.json
"module"
field. I wrote some code to download all the the package.json
files from all the public packages in the NPM registry. Here are some findings:
941 public NPM packages use the "module"
field as of 2018-10-22.
Here are the top 30 packages, as ranked by number of public dependents (or see the full list):
Dependents | Package Name | "module" Field Value |
---|---|---|
16,286 | should | ./es6/should.js |
15,472 | sinon | ./pkg/sinon-esm.js |
There is a Google Web Fundamentals article “Using JavaScript modules on the web” that explains how to use ECMAScript modules in browsers, such as via <script type="module">
. It includes a section titled “A note on file extensions” that encourages developers to use the .mjs
file extension, with the reasoning being that developers should want to tell apart their ES Module code from their Script code and also to save files for use with Node’s --experimental-modules
implementation (at least, until it’s replaced with the new version that allows ES modules in .js
files).
Most interesting to me, though, was the section “Web adoption of JS modules” with a link to usage counters
// Run this script via: node --no-warnings --experimental-fetch count-npm-package-downloads.mjs <package> | |
import { argv } from 'node:process' | |
const packageName = argv.at(-1) | |
const downloadsByMajorVersion = new Map() | |
const page = await (await fetch(`https://www.npmjs.com/package/${packageName}?activeTab=versions`)).text() | |
const regex = /">(?<version>[\d.]+)<\/a><div class="[^"]+"><\/div><code class="downloads">(?<downloads>[\d,]+)<\/code>/g |