Last active
September 5, 2020 20:40
-
-
Save anandthakker/68b1b63f2c1236e85709aae0f9f80ad9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global.fn = d => d + 1; | |
module.exports = global.fn; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// chunk1.js | |
define(['exports'], function (exports) { 'use strict'; | |
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | |
commonjsGlobal.data = [4, 5, 6]; | |
var shared = commonjsGlobal.data; | |
exports.* = commonjsGlobal; | |
exports.default = shared; | |
}); | |
// thing1.js | |
define(['./chunk1.js'], function (__chunk1_js) { 'use strict'; | |
__chunk1_js.*.fn = d => d + 1; | |
var cjs = __chunk1_js.*.fn; | |
var thing1 = __chunk1_js.default.map(cjs); | |
return thing1; | |
}); | |
// thing2.js | |
define(['./chunk1.js'], function (__chunk1_js) { 'use strict'; | |
var thing2 = __chunk1_js.default.map(d => d + 2); | |
return thing2; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import commonjs from 'rollup-plugin-commonjs'; | |
export default [{ | |
input: ['thing1.js', 'thing2.js'], | |
output: { | |
dir: 'out', | |
format: 'amd' | |
}, | |
plugins: [ | |
commonjs() | |
], | |
experimentalCodeSplitting: true | |
}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import e from './shared'; | |
import fn from './cjs'; | |
export default e.map(fn); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import d from './shared'; | |
export default d.map(d => d + 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment