Skip to content

Commit

Permalink
Test that rollup-plugin-commonjs works with preserveModules (#2792)
Browse files Browse the repository at this point in the history
* Extend filename sanitation and test that rollup-plugin-commonjs works with preserveModules

* Just adapt tests as replacing : does not work nicely on windows
  • Loading branch information
lukastaegert authored Apr 5, 2019
1 parent fee090c commit 7837fc5
Show file tree
Hide file tree
Showing 26 changed files with 307 additions and 10 deletions.
82 changes: 73 additions & 9 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
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"rollup": "^1.8.0",
"rollup-plugin-alias": "^1.5.1",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-commonjs": "^9.3.1",
"rollup-plugin-commonjs": "^9.3.3",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-replace": "^2.1.1",
Expand Down
11 changes: 11 additions & 0 deletions test/chunking-form/samples/preserve-modules-commonjs/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const commonjs = require('rollup-plugin-commonjs');

module.exports = {
description: 'Handles output from rollup-plugin-commonjs',
options: {
input: 'main.js',
preserveModules: true,
external: ['external'],
plugins: [commonjs()]
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
define(['exports', 'external'], function (exports, external) { 'use strict';

external = external && external.hasOwnProperty('default') ? external['default'] : external;



exports.default = external;

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
define(['exports', '../other.js'], function (exports, __chunk_1) { 'use strict';



exports.default = __chunk_1.__moduleExports;

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
define(['exports', 'external', './other.js', './_virtual/_commonjs-external-external', './_virtual/other.js'], function (exports, external, __chunk_1, __chunk_2, __chunk_3) { 'use strict';

external = external && external.hasOwnProperty('default') ? external['default'] : external;

const { value } = __chunk_3.default;

console.log(__chunk_2.default, value);

var commonjs = 42;

exports.__moduleExports = commonjs;
exports.default = commonjs;

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
define(['external', './commonjs.js'], function (external, __chunk_4) { 'use strict';

external = external && external.hasOwnProperty('default') ? external['default'] : external;

console.log(__chunk_4.default, external);

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
define(['exports'], function (exports) { 'use strict';

var value = 43;

var other = {
value: value
};

exports.__moduleExports = other;
exports.value = value;

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var external = _interopDefault(require('external'));



exports.default = external;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

var __chunk_1 = require('../other.js');



exports.default = __chunk_1.__moduleExports;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

require('external');
require('./other.js');
var __chunk_2 = require('./_virtual/_commonjs-external-external');
var __chunk_3 = require('./_virtual/other.js');

const { value } = __chunk_3.default;

console.log(__chunk_2.default, value);

var commonjs = 42;

exports.__moduleExports = commonjs;
exports.default = commonjs;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var external = _interopDefault(require('external'));
var __chunk_4 = require('./commonjs.js');

console.log(__chunk_4.default, external);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

var value = 43;

var other = {
value: value
};

exports.__moduleExports = other;
exports.value = value;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import external from 'external';



export default external;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { __moduleExports as other } from '../other.js';



export default other;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'external';
import './other.js';
import external from './_virtual/_commonjs-external-external';
import require$$0 from './_virtual/other.js';

const { value } = require$$0;

console.log(external, value);

var commonjs = 42;

export default commonjs;
export { commonjs as __moduleExports };
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import external from 'external';
import value from './commonjs.js';

console.log(value, external);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var value = 43;

var other = {
value: value
};

export { other as __moduleExports, value };
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
System.register(['external'], function (exports, module) {
'use strict';
var external;
return {
setters: [function (module) {
external = module.default;
}],
execute: function () {

exports('default', external);

}
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
System.register(['../other.js'], function (exports, module) {
'use strict';
var other;
return {
setters: [function (module) {
other = module.__moduleExports;
}],
execute: function () {

exports('default', other);

}
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
System.register(['external', './other.js', './_virtual/_commonjs-external-external', './_virtual/other.js'], function (exports, module) {
'use strict';
var external, require$$0;
return {
setters: [function () {}, function () {}, function (module) {
external = module.default;
}, function (module) {
require$$0 = module.default;
}],
execute: function () {

const { value } = require$$0;

console.log(external, value);

var commonjs = exports('__moduleExports', 42);
exports('default', commonjs);

}
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
System.register(['external', './commonjs.js'], function (exports, module) {
'use strict';
var external, value;
return {
setters: [function (module) {
external = module.default;
}, function (module) {
value = module.default;
}],
execute: function () {

console.log(value, external);

}
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
System.register([], function (exports, module) {
'use strict';
return {
execute: function () {

var value = exports('value', 43);

var other = exports('__moduleExports', {
value: value
});

}
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const external = require('external');
const { value } = require('./other');

console.log(external, value);

module.exports = 42;
4 changes: 4 additions & 0 deletions test/chunking-form/samples/preserve-modules-commonjs/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import value from './commonjs';
import external from 'external';

console.log(value, external);
Loading

0 comments on commit 7837fc5

Please sign in to comment.