Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Added support for ancient ES3 browsers (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
sormy authored and lukastaegert committed Apr 2, 2019
1 parent e2ba623 commit dc82347
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# rollup-plugin-commonjs changelog

## 9.2.3
*2019-03-30*
* Added support for ES3 ancient browsers ([#364](https://github.com/rollup/rollup-plugin-commonjs/issues/364))

## 9.2.2
*2019-03-25*
* Handle array destructuring assignment ([#379](https://github.com/rollup/rollup-plugin-commonjs/issues/379))
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rollup-plugin-commonjs",
"version": "9.2.2",
"version": "9.2.3",
"description": "Convert CommonJS modules to ES2015",
"main": "dist/rollup-plugin-commonjs.cjs.js",
"module": "dist/rollup-plugin-commonjs.es.js",
Expand Down
6 changes: 4 additions & 2 deletions src/helpers.js
Expand Up @@ -2,6 +2,8 @@ export const PROXY_PREFIX = '\0commonjs-proxy:';
export const EXTERNAL_PREFIX = '\0commonjs-external:';
export const HELPERS_ID = '\0commonjsHelpers';

// `x['default']` is used instead of `x.default` for backward compatibility with ES3 browsers.
// Minifiers like uglify will usually transpile it back if compatibility with ES3 is not enabled.
export const HELPERS = `
export var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
Expand All @@ -10,13 +12,13 @@ export function commonjsRequire () {
}
export function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
export function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
export function getCjsExportFromNamespace (n) {
return n && n.default || n;
return n && n['default'] || n;
}`;

0 comments on commit dc82347

Please sign in to comment.