rollup-plugin-commonjs
Advanced tools
Comparing version 1.0.0 to 1.1.0
# rollup-plugin-commonjs changelog | ||
## 1.1.0 | ||
* Handle dots in filenames ([#3](https://github.com/rollup/rollup-plugin-commonjs/issues/3)) | ||
* Wrap modules in IIFE for more readable output | ||
## 1.0.0 | ||
* Stable release, now that Rollup supports plugins | ||
## 0.2.1 | ||
@@ -4,0 +13,0 @@ |
@@ -22,18 +22,9 @@ 'use strict'; | ||
var withExtension = rollupPluginutils.addExtension(importee); | ||
var resolved = path.resolve(path.dirname(importer), withExtension); | ||
var resolved = path.resolve(path.dirname(importer), importee); | ||
var candidates = [resolved, resolved + '.js', resolved + (path.sep + 'index.js')]; | ||
// look for `foo.js`... | ||
try { | ||
fs.statSync(resolved); | ||
return resolved; | ||
} catch (err) {} | ||
// ...then `foo/index.js` | ||
if (importee !== withExtension) { | ||
for (var i = 0; i < candidates.length; i += 1) { | ||
try { | ||
resolved = resolved.replace(/\.js$/, path.sep + 'index.js'); | ||
fs.statSync(resolved); | ||
return resolved; | ||
var stats = fs.statSync(candidates[i]); | ||
if (stats.isFile()) return candidates[i]; | ||
} catch (err) {} | ||
@@ -123,6 +114,6 @@ } | ||
var intro = 'var exports = {}, module = { \'exports\': exports };\n'; | ||
var outro = '\nexport default module.exports;'; | ||
var intro = '\n\nexport default (function (module) {\nvar exports = module.exports;\n'; | ||
var outro = '\nreturn module.exports;\n})({exports:{}});'; | ||
magicString.trim().prepend(importBlock + intro).append(outro); | ||
magicString.trim().prepend(importBlock + intro).trim().append(outro); | ||
@@ -129,0 +120,0 @@ code = magicString.toString(); |
@@ -6,3 +6,3 @@ import { statSync } from 'fs'; | ||
import MagicString from 'magic-string'; | ||
import { addExtension, createFilter } from 'rollup-pluginutils'; | ||
import { createFilter } from 'rollup-pluginutils'; | ||
@@ -19,18 +19,9 @@ var firstpass = /\b(?:require|module|exports)\b/; | ||
var withExtension = addExtension(importee); | ||
var resolved = resolve(dirname(importer), withExtension); | ||
var resolved = resolve(dirname(importer), importee); | ||
var candidates = [resolved, resolved + '.js', resolved + (sep + 'index.js')]; | ||
// look for `foo.js`... | ||
try { | ||
statSync(resolved); | ||
return resolved; | ||
} catch (err) {} | ||
// ...then `foo/index.js` | ||
if (importee !== withExtension) { | ||
for (var i = 0; i < candidates.length; i += 1) { | ||
try { | ||
resolved = resolved.replace(/\.js$/, sep + 'index.js'); | ||
statSync(resolved); | ||
return resolved; | ||
var stats = statSync(candidates[i]); | ||
if (stats.isFile()) return candidates[i]; | ||
} catch (err) {} | ||
@@ -120,6 +111,6 @@ } | ||
var intro = 'var exports = {}, module = { \'exports\': exports };\n'; | ||
var outro = '\nexport default module.exports;'; | ||
var intro = '\n\nexport default (function (module) {\nvar exports = module.exports;\n'; | ||
var outro = '\nreturn module.exports;\n})({exports:{}});'; | ||
magicString.trim().prepend(importBlock + intro).append(outro); | ||
magicString.trim().prepend(importBlock + intro).trim().append(outro); | ||
@@ -126,0 +117,0 @@ code = magicString.toString(); |
{ | ||
"name": "rollup-plugin-commonjs", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "eslint": "^1.7.3", |
# rollup-plugin-commonjs | ||
**experimental – depends on an unreleased version of Rollup** | ||
Convert CommonJS modules to ES6, so they can be included in a Rollup bundle | ||
@@ -6,0 +4,0 @@ |
@@ -17,18 +17,13 @@ import { statSync } from 'fs'; | ||
let withExtension = addExtension( importee ); | ||
let resolved = resolve( dirname( importer ), withExtension ); | ||
const resolved = resolve( dirname( importer ), importee ); | ||
const candidates = [ | ||
resolved, | ||
resolved + '.js', | ||
resolved + `${sep}index.js` | ||
]; | ||
// look for `foo.js`... | ||
try { | ||
statSync( resolved ); | ||
return resolved; | ||
} catch ( err ) {} | ||
// ...then `foo/index.js` | ||
if ( importee !== withExtension ) { | ||
for ( let i = 0; i < candidates.length; i += 1 ) { | ||
try { | ||
resolved = resolved.replace( /\.js$/, `${sep}index.js` ); | ||
statSync( resolved ); | ||
return resolved; | ||
const stats = statSync( candidates[i] ); | ||
if ( stats.isFile() ) return candidates[i]; | ||
} catch ( err ) {} | ||
@@ -118,7 +113,8 @@ } | ||
const intro = `var exports = {}, module = { 'exports': exports };\n`; | ||
const outro = `\nexport default module.exports;`; | ||
const intro = `\n\nexport default (function (module) {\nvar exports = module.exports;\n`; | ||
const outro = `\nreturn module.exports;\n})({exports:{}});`; | ||
magicString.trim() | ||
.prepend( importBlock + intro ) | ||
.trim() | ||
.append( outro ); | ||
@@ -125,0 +121,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
12156
285
44