diff --git a/test/form/custom-module-context-function/_config.js b/test/form/custom-module-context-function/_config.js new file mode 100644 index 0000000..c15118e --- /dev/null +++ b/test/form/custom-module-context-function/_config.js @@ -0,0 +1,8 @@ +module.exports = { + description: 'allows custom module-specific context with a function option', + options: { + moduleContext ( id ) { + return /main\.js$/.test( id ) ? 'lolwut' : 'undefined'; + } + } +}; diff --git a/test/form/custom-module-context-function/_expected/amd.js b/test/form/custom-module-context-function/_expected/amd.js new file mode 100644 index 0000000..9274799 --- /dev/null +++ b/test/form/custom-module-context-function/_expected/amd.js @@ -0,0 +1,7 @@ +define(function () { 'use strict'; + + undefined.prop = 'nope'; + + lolwut.prop = '???'; + +}); diff --git a/test/form/custom-module-context-function/_expected/cjs.js b/test/form/custom-module-context-function/_expected/cjs.js new file mode 100644 index 0000000..35a5b08 --- /dev/null +++ b/test/form/custom-module-context-function/_expected/cjs.js @@ -0,0 +1,5 @@ +'use strict'; + +undefined.prop = 'nope'; + +lolwut.prop = '???'; diff --git a/test/form/custom-module-context-function/_expected/es.js b/test/form/custom-module-context-function/_expected/es.js new file mode 100644 index 0000000..a6903e0 --- /dev/null +++ b/test/form/custom-module-context-function/_expected/es.js @@ -0,0 +1,3 @@ +undefined.prop = 'nope'; + +lolwut.prop = '???'; diff --git a/test/form/custom-module-context-function/_expected/iife.js b/test/form/custom-module-context-function/_expected/iife.js new file mode 100644 index 0000000..7926fe6 --- /dev/null +++ b/test/form/custom-module-context-function/_expected/iife.js @@ -0,0 +1,8 @@ +(function () { + 'use strict'; + + undefined.prop = 'nope'; + + lolwut.prop = '???'; + +}()); diff --git a/test/form/custom-module-context-function/_expected/umd.js b/test/form/custom-module-context-function/_expected/umd.js new file mode 100644 index 0000000..22fa605 --- /dev/null +++ b/test/form/custom-module-context-function/_expected/umd.js @@ -0,0 +1,11 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + + undefined.prop = 'nope'; + + lolwut.prop = '???'; + +}))); diff --git a/test/form/custom-module-context-function/foo.js b/test/form/custom-module-context-function/foo.js new file mode 100644 index 0000000..a5a991d --- /dev/null +++ b/test/form/custom-module-context-function/foo.js @@ -0,0 +1 @@ +this.prop = 'nope'; diff --git a/test/form/custom-module-context-function/main.js b/test/form/custom-module-context-function/main.js new file mode 100644 index 0000000..1323b68 --- /dev/null +++ b/test/form/custom-module-context-function/main.js @@ -0,0 +1,2 @@ +import './foo.js'; +this.prop = '???'; diff --git a/test/test.js b/test/test.js index aa2bbbb..f6b36c6 100644 --- a/test/test.js +++ b/test/test.js @@ -316,6 +316,8 @@ describe( 'rollup', function () { PROFILES.forEach( profile => { it( 'generates ' + profile.format, () => { + process.chdir( FORM + '/' + dir ); + return createBundle().then( bundle => { const options = extend( {}, config.options, { dest: FORM + '/' + dir + '/_actual/' + profile.format + '.js',