Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jan 24, 2020
1 parent 16e4cff commit 0bc81a6
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 31 deletions.
@@ -0,0 +1,7 @@
module.exports = {
description: 'supports an object with a single entry when inlining dynamic imports',
options: {
inlineDynamicImports: true,
input: { entry: 'main' }
}
};
@@ -0,0 +1,17 @@
define(['exports'], function (exports) { 'use strict';

const bar = 2;
Promise.resolve().then(function () { return foo$1; });

const foo = 1;

var foo$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
foo: foo
});

exports.bar = bar;

Object.defineProperty(exports, '__esModule', { value: true });

});
@@ -0,0 +1,15 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const bar = 2;
Promise.resolve().then(function () { return foo$1; });

const foo = 1;

var foo$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
foo: foo
});

exports.bar = bar;
@@ -0,0 +1,11 @@
const bar = 2;
Promise.resolve().then(function () { return foo$1; });

const foo = 1;

var foo$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
foo: foo
});

export { bar };
@@ -0,0 +1,18 @@
System.register([], function (exports) {
'use strict';
return {
execute: function () {

const bar = exports('bar', 2);
Promise.resolve().then(function () { return foo$1; });

const foo = 1;

var foo$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
foo: foo
});

}
};
});
@@ -0,0 +1 @@
export const foo = 1;
@@ -0,0 +1,2 @@
export const bar = 2;
import('./foo.js');
7 changes: 7 additions & 0 deletions test/form/samples/dynamic-import-inlining-array/_config.js
@@ -0,0 +1,7 @@
module.exports = {
description: 'supports an array with a single entry when inlining dynamic imports',
options: {
inlineDynamicImports: true,
input: ['main']
}
};
11 changes: 11 additions & 0 deletions test/form/samples/dynamic-import-inlining-array/_expected.js
@@ -0,0 +1,11 @@
const bar = 2;
Promise.resolve().then(function () { return foo$1; });

const foo = 1;

var foo$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
foo: foo
});

export { bar };
1 change: 1 addition & 0 deletions test/form/samples/dynamic-import-inlining-array/foo.js
@@ -0,0 +1 @@
export const foo = 1;
2 changes: 2 additions & 0 deletions test/form/samples/dynamic-import-inlining-array/main.js
@@ -0,0 +1,2 @@
export const bar = 2;
import('./foo.js');
10 changes: 1 addition & 9 deletions test/function/samples/dynamic-import-duplicates/_config.js
@@ -1,17 +1,9 @@
const assert = require('assert');
const path = require('path');

module.exports = {
description: 'Dynamic import inlining',
options: {
inlineDynamicImports: true,
plugins: [
{
resolveDynamicImport(specifier, parent) {
if (specifier === './main') return path.resolve(__dirname, 'main.js');
}
}
]
inlineDynamicImports: true
},
exports(exports) {
assert.equal(exports.x, 41);
Expand Down
10 changes: 0 additions & 10 deletions test/function/samples/dynamic-import-existing/_config.js
@@ -1,17 +1,7 @@
const assert = require('assert');
const path = require('path');

module.exports = {
description: 'Dynamic import inlining when resolution id is a module in the bundle',
options: {
plugins: [
{
resolveDynamicImport(specifier, parent) {
if (specifier === './main') return path.resolve(__dirname, 'main.js');
}
}
]
},
exports(exports) {
assert.equal(exports.y, 42);
return Promise.resolve(exports.promise).then(val => {
Expand Down
2 changes: 1 addition & 1 deletion test/function/samples/dynamic-import-expression/_config.js
Expand Up @@ -5,7 +5,7 @@ module.exports = {
options: {
plugins: [
{
resolveDynamicImport(specifier, parent) {
resolveDynamicImport(specifier) {
if (typeof specifier !== 'string') {
// string literal concatenation
if (
Expand Down
10 changes: 1 addition & 9 deletions test/function/samples/dynamic-import-inlining/_config.js
@@ -1,17 +1,9 @@
const assert = require('assert');
const path = require('path');

module.exports = {
description: 'Dynamic import inlining',
options: {
inlineDynamicImports: true,
plugins: [
{
resolveDynamicImport(specifier, parent) {
if (specifier === './main') return path.resolve(__dirname, 'main.js');
}
}
]
inlineDynamicImports: true
},
exports(exports) {
assert.equal(exports.x, 41);
Expand Down
2 changes: 1 addition & 1 deletion test/function/samples/dynamic-import-rewriting/_config.js
Expand Up @@ -6,7 +6,7 @@ module.exports = {
external: ['asdf'],
plugins: [
{
resolveDynamicImport(specifier, parent) {
resolveDynamicImport() {
return 'asdf';
}
}
Expand Down
@@ -1,5 +1,5 @@
module.exports = {
description: 'Having multiple inputs is not supported when inlining dynamic imports',
description: 'Having multiple inputs in an array is not supported when inlining dynamic imports',
options: {
input: ['main.js', 'lib.js'],
inlineDynamicImports: true
Expand Down
@@ -0,0 +1,11 @@
module.exports = {
description: 'Having multiple inputs in an object is not supported when inlining dynamic imports',
options: {
input: { main: 'main.js', lib: 'lib.js' },
inlineDynamicImports: true
},
error: {
code: 'INVALID_OPTION',
message: 'Multiple inputs are not supported for "inlineDynamicImports".'
}
};
@@ -0,0 +1 @@
export const value = 42;
@@ -0,0 +1 @@
import('./lib').then(({value}) => assert.equal(value, 42));

0 comments on commit 0bc81a6

Please sign in to comment.