Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js native ESM support #2914

Merged
merged 29 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7e7e6d9
Add type: commonjs to the package.json
jgonggrijp Mar 8, 2021
6c0cddd
Add an extra package.json with type: module in the modules/
jgonggrijp Mar 8, 2021
4fc14f1
Refactor the rollup config a bit
jgonggrijp Mar 8, 2021
4bbf9eb
Upgrade rollup
jgonggrijp Mar 8, 2021
2a604f0
Add custom rollup builds for the new Node.js ESM support
jgonggrijp Mar 8, 2021
5c0cb90
Reorder package.json
jgonggrijp Mar 8, 2021
57a4a0e
Rename underscore.js to underscore-umd.js, keep underscore.js as alias
jgonggrijp Mar 8, 2021
e524023
Add the scary new exports field to the package.json
jgonggrijp Mar 9, 2021
6639c23
Bump the version to 1.13.0-0
jgonggrijp Mar 9, 2021
892c341
Update the minified bundles
jgonggrijp Mar 9, 2021
58d0e20
Update the annotated source
jgonggrijp Mar 9, 2021
c4a6dbe
Add 1.13.0-0 entry to the change log
jgonggrijp Mar 9, 2021
c521426
Remove the package-lock.json from the exports
jgonggrijp Mar 9, 2021
f9cf7af
Mark monolithic imports as recommended
jgonggrijp Mar 9, 2021
645f8fa
Add a note about the PR to the documentation
jgonggrijp Mar 10, 2021
36a3bc8
Merge branch 'master' into node-native-esm
jgonggrijp Mar 10, 2021
9dd137c
Downgrade Rollup when running Travis CI with Node.js v8
jgonggrijp Mar 10, 2021
45afe0e
Switch to Node.js v14 for SauceLabs testing while I'm at it
jgonggrijp Mar 10, 2021
04b639c
Generate Node.js build in two stages
jgonggrijp Mar 11, 2021
5e3da47
Bump the version to 1.13.0-1
jgonggrijp Mar 11, 2021
0345136
Add 1.13.0-1 entry to the change log
jgonggrijp Mar 11, 2021
9f88a5e
Update generated docs and minified bundles, tag v1.13.0-1
jgonggrijp Mar 11, 2021
52300cc
Merge branch 'master' into node-native-esm
jgonggrijp Mar 14, 2021
87b5ecd
Bump the version to 1.13.0-2
jgonggrijp Mar 14, 2021
c9040fb
Add 1.13.0-2 to the change log
jgonggrijp Mar 14, 2021
163f032
Add diff and docs to the 1.12.1 change log entry
jgonggrijp Mar 14, 2021
9fded0c
Merge branch 'master' into node-native-esm
jgonggrijp Mar 29, 2021
d6d0f57
Add "module" exports condition to the package.json
jgonggrijp Mar 29, 2021
62c6ad0
Cut 1.13.0-3 preview release
jgonggrijp Mar 31, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ coverage
test-treeshake/*-umd.js
amd
cjs
/underscore.js
/underscore-min.js
/underscore-min.js.map
/underscore-node-*-pre*
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ sudo: false
jobs:
include:
- node_js: 8
env: EXTRA=false
env:
- DOWNGRADE=true
- EXTRA=false
- node_js: 10
env: EXTRA=true
env:
- DOWNGRADE=false
- EXTRA=false
- node_js: 14
env: EXTRA=false
env:
- DOWNGRADE=false
- EXTRA=true
before_install:
- npm install -g karma-cli
before_script:
- npm install karma-sauce-launcher
- "[ $DOWNGRADE = false ] || npm install rollup@1"
script:
- npm test
- "[ $EXTRA = false ] || npm run test-browser"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/underscore/blob/master/modules/index.js).

* In your pull request, do not add documentation or re-build the minified `underscore-min.js` file. We'll do those things before cutting a new release.
* In your pull request, do not add documentation or re-build the minified `underscore-umd-min.js` file. We'll do those things before cutting a new release.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "underscore",
"main": "underscore.js",
"main": "underscore-umd.js",
"keywords": ["util", "functional", "server", "client", "browser"],
"ignore" : ["docs", "test", "*.yml", "CNAME", "index.html", "favicon.ico", "CONTRIBUTING.md", ".*", "package.json", "karma.*"]
}
2 changes: 1 addition & 1 deletion docs/modules/_setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ <h1>_setup.js</h1>

</div>

<div class="content"><div class='highlight'><pre><span class="hljs-keyword">export</span> <span class="hljs-keyword">var</span> VERSION = <span class="hljs-string">'1.12.1'</span>;</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">export</span> <span class="hljs-keyword">var</span> VERSION = <span class="hljs-string">'1.13.0-3'</span>;</pre></div></div>

</li>

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ <h1 id="named-exports">Named Exports</h1>
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
</div>
<pre><code>Underscore.js <span class="hljs-number">1.12</span><span class="hljs-number">.1</span>
<pre><code>Underscore.js <span class="hljs-number">1.13</span><span class="hljs-number">.0</span><span class="hljs-number">-3</span>
<span class="hljs-attr">https</span>:<span class="hljs-comment">//underscorejs.org</span>
(c) <span class="hljs-number">2009</span><span class="hljs-number">-2020</span> Jeremy Ashkenas, DocumentCloud and Investigative Reporters &amp; Editors
Underscore may be freely distributed under the MIT license.</code></pre>
Expand Down
124 changes: 62 additions & 62 deletions docs/underscore-esm.html

Large diffs are not rendered by default.

126 changes: 94 additions & 32 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<div id="sidebar" class="interface">

<a class="toc_title" href="#">
Underscore.js <span class="version">(1.12.1)</span>
Underscore.js <span class="version">(1.13.0-3)</span>
</a>
<ul class="toc_section">
<li>&raquo; <a href="https://github.com/jashkenas/underscore">GitHub Repository</a></li>
Expand Down Expand Up @@ -440,23 +440,20 @@
</p>

<p>
You may choose between monolithic and modular imports. There is a quick
summary of the options below, as well as a more comprehensive
discussion in <a
href="https://juliangonggrijp.com/article/introducing-modular-underscore.html"
>the article</a>.
You may choose between monolithic and modular imports. There is a quick
summary of the options below, as well as a more comprehensive
discussion in <a
href="https://juliangonggrijp.com/article/introducing-modular-underscore.html"
>the article</a>.
</p>

<p>
<i><a
href="https://cdn.statically.io/gh/jashkenas/underscore/1.13.0-1/index.html"
>Prerelease version 1.13.0-1</a> adds full support for native ESM
imports in Node.js version 12 and later. It should do this without
breaking existing setups. Please try it out by installing
<i>Prerelease version 1.13.0-1 adds full support for native ESM imports
in Node.js version 12 and later. It should do this without breaking
existing setups. Please try it out by installing
<tt>underscore@preview</tt> from NPM and let us know whether it worked
for you in <a
href="https://github.com/jashkenas/underscore/pull/2914"
>the pull request</a>!</i>
for you in <a href="https://github.com/jashkenas/underscore/pull/2914">the
pull request</a>!</i>
</p>

<p>
Expand All @@ -476,7 +473,7 @@
<i>Underscore is an open-source component of <a href="https://documentcloud.org/">DocumentCloud</a>.</i>
</p>

<h2>v1.12.1 Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and use "Save As")</i></h2>
<h2>v1.13.0-3 Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and use "Save As")</i></h2>

<table>
<tr>
Expand All @@ -494,17 +491,17 @@ <h2>v1.12.1 Downloads <i style="padding-left: 12px; font-size:12px;">(Right-clic
</td>
</tr>
<tr>
<td class="dl-link"><a href="underscore.js">UMD (Development)</a></td>
<td class="dl-link"><a href="underscore-umd.js">UMD (Development)</a></td>
<td>
<i>67.45kb, Uncompressed with Bountiful Comments</i>
&nbsp;<small>(<a href="underscore.js.map">Source Map</a>)</small>
&nbsp;<small>(<a href="underscore-umd.js.map">Source Map</a>)</small>
</td>
</tr>
<tr>
<td class="dl-link"><a href="underscore-min.js">UMD (Production)</a></td>
<td class="dl-link"><a href="underscore-umd-min.js">UMD (Production)</a></td>
<td>
<i>7.39kb, Minified and Gzipped</i>
&nbsp;<small>(<a href="underscore-min.js.map">Source Map</a>)</small>
&nbsp;<small>(<a href="underscore-umd-min.js.map">Source Map</a>)</small>
</td>
</tr>
<tr>
Expand All @@ -515,37 +512,37 @@ <h2>v1.12.1 Downloads <i style="padding-left: 12px; font-size:12px;">(Right-clic
<td><i>Unreleased, current <tt>master</tt>, use by your own judgement and at your own risk</i></td>
</tr>
<tr>
<td class="dl-link"><a href="https://raw.github.com/jashkenas/underscore/master/underscore.js">Edge UMD</a></td>
<td class="dl-link"><a href="https://raw.github.com/jashkenas/underscore/master/underscore-umd.js">Edge UMD</a></td>
<td><i>Unreleased, current <tt>master</tt>, use if you’re feeling lucky</i></td>
</tr>
</table>

<h2>v1.12.1 CDN URLs <i style="padding-left: 12px; font-size:12px;">(Use with <tt>&lt;script src="..."&gt;&lt;/script&gt;</tt>)</i></h2>
<h2>v1.13.0-3 CDN URLs <i style="padding-left: 12px; font-size:12px;">(Use with <tt>&lt;script src="..."&gt;&lt;/script&gt;</tt>)</i></h2>

<ul>
<li>
<tt>https://cdn.jsdelivr.net/npm/underscore@1.12.1/underscore-min.js</tt>
<tt>https://cdn.jsdelivr.net/npm/underscore@1.13.0-3/underscore-umd-min.js</tt>
</li>
<li>
<tt>https://cdn.jsdelivr.net/npm/underscore@1.12.1/underscore-esm-min.js</tt>
<tt>https://cdn.jsdelivr.net/npm/underscore@1.13.0-3/underscore-esm-min.js</tt>
</li>
<li>
<tt>https://unpkg.com/underscore@1.12.1/underscore-min.js</tt>
<tt>https://unpkg.com/underscore@1.13.0-3/underscore-umd-min.js</tt>
</li>
<li>
<tt>https://unpkg.com/underscore@1.12.1/underscore-esm-min.js</tt>
<tt>https://unpkg.com/underscore@1.13.0-3/underscore-esm-min.js</tt>
</li>
<li>
<tt>https://pagecdn.io/lib/underscore/1.12.1/underscore-min.js</tt>
<tt>https://pagecdn.io/lib/underscore/1.13.0-3/underscore-umd-min.js</tt>
</li>
<li>
<tt>https://pagecdn.io/lib/underscore/1.12.1/underscore-esm-min.js</tt>
<tt>https://pagecdn.io/lib/underscore/1.13.0-3/underscore-esm-min.js</tt>
</li>
<li>
<tt>https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.12.1/underscore-min.js</tt>
<tt>https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.0-3/underscore-umd-min.js</tt>
</li>
<li>
<tt>https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.12.1/underscore-esm-min.js</tt>
<tt>https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.0-3/underscore-esm-min.js</tt>
</li>
</ul>

Expand All @@ -563,7 +560,7 @@ <h2>Package Installation</h2>
</li>
</ul>

<h2>Monolithic Import</h2>
<h2>Monolithic Import (recommended)</h2>

<ul>
<li>
Expand All @@ -576,7 +573,7 @@ <h2>Monolithic Import</h2>
<b>CommonJS</b> <tt>var _ = require('underscore');</tt>
</li>
<li>
<b>ExtendScript</b> <tt>#include "underscore.js"</tt>
<b>ExtendScript</b> <tt>#include "underscore-umd.js"</tt>
</li>
</ul>

Expand Down Expand Up @@ -2705,6 +2702,31 @@ <h2 id="notes">Notes</h2>

<h2 id="changelog">Change Log</h2>

<p id="1.13.0-3">
<b class="header">1.13.0-3</b> &mdash; <small><i>March 31, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.0-2...1.13.0-3">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.13.0-3/index.html">Docs</a><br />
<ul>
<li>
Adds a <tt>"module"</tt> exports condition to the
<tt>package.json</tt>, which should theoretically help to avoid
duplicate code bundling with <tt>exports</tt>-aware build tools.
</li>
<li>
Re-synchronizes some comments and documentation text with the
1.12.x branch.
</li>
</ul>
</p>

<p id="1.13.0-2">
<b class="header">1.13.0-2</b> &mdash; <small><i>March 15, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.0-1...1.13.0-2">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.13.0-2/index.html">Docs</a><br />
<ul>
<li>
Fixes the same security issue in <tt>_.template</tt> as the
parallel 1.12.1 release.
</li>
</ul>
</p>

<p id="1.12.1">
<b class="header">1.12.1</b> &mdash; <small><i>March 15, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.12.0...1.12.1">Diff</a> &mdash; <a href="https://cdn.statically.io/gh/jashkenas/underscore/1.12.1/index.html">Docs</a><br />
<ul>
Expand All @@ -2718,6 +2740,46 @@ <h2 id="changelog">Change Log</h2>
href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23358"
>CVE-2021-23358</a>
</li>
<li>
Restores an optimization in <tt>_.debounce</tt> that was
unintentionally lost in version 1.9.0 (same as in parallel preview
release 1.13.0-0).
</li>
<li>
Various test and documentation enhancements (same as in parallel
preview releases 1.13.0-0 and 1.13.0-1).
</li>
</ul>
</p>

<p id="1.13.0-1">
<b class="header">1.13.0-1</b> &mdash; <small><i>March 11, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.13.0-0...1.13.0-1">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.13.0-1/index.html">Docs</a><br />
<ul>
<li>
Fixes an issue that caused aliases to be absent among the named
exports in the new native ESM entry point for Node.js 12+.
</li>
<li>
More test and documentation fixes and enhancements.
</li>
</ul>
</p>

<p id="1.13.0-0">
<b class="header">1.13.0-0</b> &mdash; <small><i>March 9, 2021</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.12.0...1.13.0-0">Diff</a> &mdash; <a href="https://cdn.rawgit.com/jashkenas/underscore/1.13.0-0/index.html">Docs</a><br />
<ul>
<li>
Adds experimental support for native ESM imports in Node.js. You
can now also do named imports or even deep module imports directly
from a Node.js process in Node.js version 12 and later. Monolithic
imports are recommended for use in production. State (such as
mixed-in functions) is shared between CommonJS and ESM consumers.
</li>
<li>
Renames the UMD bundle to <tt>underscore-umd.js</tt> for
consistency with the other bundle names. An alias named
<tt>underscore.js</tt> is retained for backwards compatibility.
</li>
<li>
Restores an optimization in <tt>_.debounce</tt> that was
unintentionally lost in version 1.9.0.
Expand Down Expand Up @@ -3928,7 +3990,7 @@ <h2 id="changelog">Change Log</h2>
</div>

<!-- Include Underscore, so you can play with it in the console. -->
<script type="text/javascript" src="underscore.js"></script>
<script type="text/javascript" src="underscore-umd.js"></script>
<script type="text/javascript" src="docs/main.js"></script>

</body>
Expand Down
2 changes: 1 addition & 1 deletion karma.conf-sauce.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = function(config) {
files: [
'test/vendor/qunit-extras.js',
'test/qunit-setup.js',
'underscore.js',
'underscore-umd.js',
'test/*.js'
],

Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'test/qunit-setup.js',
'underscore.js',
'underscore-umd.js',
'test/*.js'
],

Expand Down
2 changes: 1 addition & 1 deletion modules/_setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Current version.
export var VERSION = '1.12.1';
export var VERSION = '1.13.0-3';

// Establish the root object, `window` (`self`) in the browser, `global`
// on the server, or `this` in some virtual machines. We use `self`
Expand Down
2 changes: 1 addition & 1 deletion modules/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Named Exports
// =============

// Underscore.js 1.12.1
// Underscore.js 1.13.0-3
// https://underscorejs.org
// (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
Expand Down
3 changes: 3 additions & 0 deletions modules/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Loading