Skip to content

Commit

Permalink
move test to chunking-form/samples
Browse files Browse the repository at this point in the history
  • Loading branch information
tjenkinson committed Nov 15, 2020
1 parent 2e9d487 commit cb76695
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/chunking-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runTestSuiteWithSamples('chunking form', path.resolve(__dirname, 'samples'), (di
() => {
let bundle;

for (const format of FORMATS) {
for (const format of [...FORMATS, ...(config.additionalFormats || [])]) {
it('generates ' + format, async () => {
process.chdir(dir);
bundle =
Expand Down Expand Up @@ -59,7 +59,7 @@ runTestSuiteWithSamples('chunking form', path.resolve(__dirname, 'samples'), (di

async function generateAndTestBundle(bundle, outputOptions, expectedDir, config) {
await bundle.write(outputOptions);
if (outputOptions.format === 'amd' && config.runAmd) {
if (['amd', 'umd'].includes(outputOptions.format) && config.runAmd) {
await new Promise(resolve => {
global.assert = require('assert');
const requirejs = require('requirejs');
Expand Down
17 changes: 17 additions & 0 deletions test/chunking-form/samples/amd-id-code-split/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
solo: true,
description: 'handles amd.id with the [id] pattern',
options: {
input: ['main'],
output: {
name: 'outputName',
amd: {
id: 'something/[id]'
}
}
},
additionalFormats: ['umd'],
runAmd: exports => {
return exports.getA();
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
define('something/main', ['exports'], function (exports) { 'use strict';

const something = 42;

exports.something = something;

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

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

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

const something = 42;

exports.something = something;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const something = 42;

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

const something = exports('something', 42);

}
};
});
13 changes: 13 additions & 0 deletions test/chunking-form/samples/amd-id-code-split/_expected/umd/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define('something/main', ['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.outputName = {}));
}(this, (function (exports) { 'use strict';

const something = 42;

exports.something = something;

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

})));
1 change: 1 addition & 0 deletions test/chunking-form/samples/amd-id-code-split/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const something = 42;
13 changes: 13 additions & 0 deletions test/chunking-form/samples/amd-id/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
solo: true,
description: 'handles amd.id with the [id] pattern and code splitting',
options: {
input: ['main'],
output: {
amd: {
id: 'something/[id]'
}
}
},
runAmd: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
define('something/generated-a', ['exports'], function (exports) { 'use strict';

const something = 42;

exports.something = something;

});
11 changes: 11 additions & 0 deletions test/chunking-form/samples/amd-id/_expected/amd/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
define('something/main', ['require', 'exports'], function (require, exports) { 'use strict';

function getA() {
return new Promise(function (resolve, reject) { require(['./generated-a'], resolve, reject) });
}

exports.getA = getA;

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

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

const something = 42;

exports.something = something;
9 changes: 9 additions & 0 deletions test/chunking-form/samples/amd-id/_expected/cjs/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

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

function getA() {
return Promise.resolve().then(function () { return require('./generated-a.js'); });
}

exports.getA = getA;
3 changes: 3 additions & 0 deletions test/chunking-form/samples/amd-id/_expected/es/generated-a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const something = 42;

export { something };
5 changes: 5 additions & 0 deletions test/chunking-form/samples/amd-id/_expected/es/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function getA() {
return import('./generated-a.js');
}

export { getA };
10 changes: 10 additions & 0 deletions test/chunking-form/samples/amd-id/_expected/system/generated-a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
System.register([], function (exports) {
'use strict';
return {
execute: function () {

const something = exports('something', 42);

}
};
});
14 changes: 14 additions & 0 deletions test/chunking-form/samples/amd-id/_expected/system/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
System.register([], function (exports, module) {
'use strict';
return {
execute: function () {

exports('getA', getA);

function getA() {
return module.import('./generated-a.js');
}

}
};
});
1 change: 1 addition & 0 deletions test/chunking-form/samples/amd-id/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const something = 42;
3 changes: 3 additions & 0 deletions test/chunking-form/samples/amd-id/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getA() {
return import('./a');
}

0 comments on commit cb76695

Please sign in to comment.