rollup-plugin-es3
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,7 +5,18 @@ 'use strict'; | ||
function es3 () { | ||
function es3 (removeArr) { | ||
var removeHash = { | ||
'defineProperty': [/^\s*Object\.defineProperty\(\s*exports,\s*'__esModule'.*\n$/mg, ''], | ||
'freeze': [/Object.freeze\s*\(\s*([^)]*)\)/g, '$1'] | ||
} | ||
if (!Array.isArray(removeArr)) removeArr = Object.keys(removeHash) | ||
return { | ||
name: 'es3', | ||
transformBundle: function (code, b) { | ||
return code.replace(/^\s*Object\.defineProperty\(\s*exports,\s*'__esModule'.*\n$/m, '') | ||
transformBundle: function (code) { | ||
for (var k in removeHash) { | ||
if (removeArr.indexOf(k) > -1) { | ||
code = code.replace(removeHash[k][0], removeHash[k][1]) | ||
} | ||
} | ||
return code | ||
} | ||
@@ -12,0 +23,0 @@ } |
// Make rollup compatible with ES3, remove Object.defineProperty of __esModule part | ||
function es3 () { | ||
function es3 (removeArr) { | ||
var removeHash = { | ||
'defineProperty': [/^\s*Object\.defineProperty\(\s*exports,\s*'__esModule'.*\n$/mg, ''], | ||
'freeze': [/Object.freeze\s*\(\s*([^)]*)\)/g, '$1'] | ||
} | ||
if (!Array.isArray(removeArr)) removeArr = Object.keys(removeHash) | ||
return { | ||
name: 'es3', | ||
transformBundle: function (code, b) { | ||
return code.replace(/^\s*Object\.defineProperty\(\s*exports,\s*'__esModule'.*\n$/m, '') | ||
transformBundle: function (code) { | ||
for (var k in removeHash) { | ||
if (removeArr.indexOf(k) > -1) { | ||
code = code.replace(removeHash[k][0], removeHash[k][1]) | ||
} | ||
} | ||
return code | ||
} | ||
@@ -9,0 +20,0 @@ } |
{ | ||
"name": "rollup-plugin-es3", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Make rollup compatible with ES3, remove Object.defineProperty of __esModule part", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup-plugin-es3.cjs.js", |
@@ -7,5 +7,6 @@ # rollup-plugin-es3 | ||
Currently it's only do one thing: | ||
Currently it's only do 2 things: | ||
- Remove Object.defineProperty of __esModule part | ||
- Remove Object.defineProperty of __esModule part (rollup issue [#750](https://github.com/rollup/rollup/issues/750)) | ||
- Remove Object.freeze (issue #1) | ||
@@ -32,1 +33,10 @@ ## Install | ||
## Option | ||
``` javascript | ||
// pass the list of removal | ||
plugins: [ | ||
es3(['defineProperty', 'freeze']) | ||
] | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4105
39
41