The actual snapshot is saved in function.js.snap
.
Generated by AVA.
Snapshot 1
{
'main.js': `'use strict';β
β
var foo$2 = {exports: {}};β
β
const foo = {};β
β
foo$2.exports = foo;β
foo$2.exports.bar = 1;β
β
var foo$1 = foo$2.exports;β
β
t.is(foo$1.bar, 1);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var document$2 = {exports: {}};β
β
/* eslint-disable */β
β
if (typeof document !== 'undefined') {β
document$2.exports = document;β
} else {β
document$2.exports = { fake: true };β
}β
β
var document$1 = document$2.exports;β
β
t.deepEqual(document$1, { real: true });β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
Math.bar = 42;β
β
t.is(Math.bar, 42);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
// Great moduleβ
Math.bar = 42;β
β
t.is(Math.bar, 42);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var foo$1 = 21;β
β
const foo = foo$1;β
β
var main = foo * 2;β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
Object.defineProperty(exports, '__esModule', { value: true });β
β
var main$1 = {};β
β
var dep$1 = {};β
β
const main = main$1;β
β
dep$1.getMain = () => main;β
β
const dep = dep$1;β
β
var foo = main$1.foo = 'foo';β
t.is(dep.getMain().foo, 'foo');β
β
exports["default"] = main$1;β
exports.foo = foo;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
Object.defineProperty(exports, '__esModule', { value: true });β
β
var main = {};β
β
var dep = {};β
β
(function (exports) {β
const main$1 = main;β
β
addExports(exports);β
β
function addExports(exported) {β
// eslint-disable-next-line no-param-reassignβ
exported.getMain = () => main$1;β
}β
}(dep));β
β
(function (exports) {β
const dep$1 = dep;β
β
addExports();β
t.is(dep$1.getMain().foo, 'foo');β
β
function addExports(exported) {β
// eslint-disable-next-line no-param-reassignβ
exports.foo = 'foo';β
}β
}(main));β
β
exports["default"] = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
console.log('main');β
`,
}
Snapshot 1
{
'bundle.js': `'use strict';β
β
var dashName = true;β
β
t.truthy(dashName);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var someValue$1 = {};β
β
someValue$1.someValue = 10;β
β
const someValueModule = someValue$1;β
β
var someValue = someValueModule.someValue;β
β
t.is(someValue, 10);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var foo_bar = 'fubar';β
β
const status = foo_bar;β
β
t.is(status, 'fubar');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var dep = {};β
β
dep.foo = 'first';β
dep.foo = 'second';β
β
t.is(dep.foo, 'second');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var foo = 'first';β
foo = 'second';β
β
t.is(foo, 'second');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var dep = 'first';β
dep = 'second';β
β
var dep$1 = dep;β
β
t.is(dep$1, 'second');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var x$2 = {exports: {}};β
β
const x = {};β
β
x$2.exports = x;β
x$2.exports.default = x;β
β
var x$1 = x$2.exports;β
β
t.is(x$1.default, x$1);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var x$2 = {exports: {}};β
β
const x = {};β
β
x$2.exports = x;β
x$2.exports.default = 42;β
β
var x$1 = x$2.exports;β
β
t.deepEqual(x$1, { default: 42 });β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var exports$1 = {};β
β
var Foo = exports$1.Foo = 1;β
var _var = exports$1.var = 'VAR';β
exports$1.default = {β
Foo: 2,β
default: 3β
};β
β
/* eslint-disable */β
β
t.is(exports$1.Foo, 1);β
t.is(exports$1.var, 'VAR');β
t.deepEqual(exports$1.default, { Foo: 2, default: 3 });β
t.is(exports$1.default.Foo, 2);β
t.is(exports$1.default.default, 3);β
t.is(Foo, 1);β
t.is(_var, 'VAR');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function createModule(modulePath) {β
return {β
path: modulePath,β
exports: {},β
require: function (path, base) {β
return commonjsRequire(path, base == null ? modulePath : base);β
}β
};β
}β
β
function commonjsRegister$1 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main$1 = createModule("/$$rollup_base$$/fixtures/function/dynamic-module-require");β
β
const commonjsRegister = commonjsRegister$1;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-module-require/submodule.js", function (module, exports) {β
module.exports = function () {β
return 'Hello there';β
};β
β
});β
β
(function (module) {β
/* eslint-disable import/no-dynamic-require, global-require */β
β
let message;β
β
function takeModule(withName) {β
return module.require(`./${withName}`);β
}β
β
try {β
const submodule = takeModule('submodule');β
message = submodule();β
} catch (err) {β
({ message } = err);β
}β
β
t.is(message, 'Hello there');β
}(main$1));β
β
var main = main$1.exports;β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$1 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister = commonjsRegister$1;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require/submodule.js", function (module, exports) {β
module.exports = function () {β
return 'Hello there';β
};β
β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
let message;β
β
function takeModule(withName) {β
return commonjsRequire(`./${withName}`,"/$$rollup_base$$/fixtures/function/dynamic-require");β
}β
β
try {β
const submodule = takeModule('submodule');β
message = submodule();β
} catch (err) {β
({ message } = err);β
}β
β
t.is(message, 'Hello there');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$3 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$2 = commonjsRegister$3;β
commonjsRegister$2("/$$rollup_base$$/fixtures/function/dynamic-require-absolute-import/sub/node_modules/module/direct.js", function (module, exports) {β
module.exports = 'direct';β
β
});β
β
const commonjsRegister$1 = commonjsRegister$3;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-absolute-import/sub/node_modules/module/nested/nested.js", function (module, exports) {β
module.exports = 'nested';β
β
});β
β
const commonjsRegister = commonjsRegister$3;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-absolute-import/node_modules/parent-module/parent.js", function (module, exports) {β
module.exports = 'parent';β
β
});β
β
var submodule = {};β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(name) {β
return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-absolute-import/sub");β
}β
β
submodule.moduleDirect = takeModule('module/direct');β
submodule.moduleNested = takeModule('module/nested/nested');β
submodule.parentModule = takeModule('parent-module/parent');β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
t.deepEqual(submodule, {β
moduleDirect: 'direct',β
moduleNested: 'nested',β
parentModule: 'parent'β
});β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$2 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
function commonjsRegisterOrShort$1 (path, to) {β
const resolvedPath = commonjsResolveImpl(path, null);β
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
} else {β
DYNAMIC_REQUIRE_SHORTS[path] = to;β
}β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$1 = commonjsRegister$2;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference/node_modules/custom-module/index.js", function (module, exports) {β
module.exports = {β
foo: 'bar',β
};β
β
});β
β
function mv(from, to) {β
for (let [key, value] of Object.entries(from)) {β
to[key] = value;β
}β
}β
β
function clear(obj) {β
for (let key of Array.from(Object.keys(obj))) {β
delete obj[key];β
}β
}β
β
var stealthy = function stealth(cacheObject, cb) {β
let orig = Object.create(null);β
β
mv(cacheObject, orig);β
clear(cacheObject);β
β
let res = cb();β
β
clear(cacheObject);β
mv(orig, cacheObject);β
β
return res;β
};β
β
const commonjsRegister = commonjsRegister$2;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference/node_modules/custom-module2/index.js", function (module, exports) {β
const stealthRequire = stealthy;β
β
module.exports = stealthRequire(commonjsRequire.cache, () => {β
let m = commonjsRequire("custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference/node_modules/custom-module2");β
m.foo = 'baz';β
return m;β
});β
β
});β
β
const commonjsRegisterOrShort = commonjsRegisterOrShort$1;β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference/node_modules/custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference/node_modules/custom-module/index.js");β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference/node_modules/custom-module2", "/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference/node_modules/custom-module2/index.js");β
β
const a = commonjsRequire("custom-module2", "/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference");β
const b = commonjsRequire("custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-cache-reference");β
β
t.is(a.foo, 'baz');β
t.is(b.foo, 'bar');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'generated-lib2.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$2 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
const commonjsRegister$1 = commonjsRegister$2;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-code-splitting/target1.js", function (module, exports) {β
module.exports = '1';β
β
});β
β
const commonjsRegister = commonjsRegister$2;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-code-splitting/target2.js", function (module, exports) {β
module.exports = '2';β
β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
let message;β
β
for (const index of [1, 2]) {β
try {β
message = commonjsRequire(`./target${index}.js`,"/$$rollup_base$$/fixtures/function/dynamic-require-code-splitting");β
} catch (err) {β
({ message } = err);β
}β
t.is(message, index.toString());β
}β
β
exports.commonjsRequire = commonjsRequire;β
`,
'main.js': `'use strict';β
β
var lib2 = require('./generated-lib2.js');β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
let message;β
β
for (const index of [1, 2]) {β
try {β
message = lib2.commonjsRequire(`./target${index}.js`,"/$$rollup_base$$/fixtures/function/dynamic-require-code-splitting");β
} catch (err) {β
({ message } = err);β
}β
t.is(message, index.toString());β
}β
`,
'main2.js': `'use strict';β
β
require('./generated-lib2.js');β
β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$1 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
const commonjsRegister = commonjsRegister$1;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-es-entry/submodule.js", function (module, exports) {β
module.exports = 'submodule';β
β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return commonjsRequire(`./${withName}`,"/$$rollup_base$$/fixtures/function/dynamic-require-es-entry");β
}β
β
var importer = takeModule('submodule.js');β
β
t.is(importer, 'submodule');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$1 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister = commonjsRegister$1;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-extensions/submodule.js", function (module, exports) {β
module.exports = { name: 'submodule', value: null };β
β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return commonjsRequire(`./${withName}`,"/$$rollup_base$$/fixtures/function/dynamic-require-extensions");β
}β
β
const withExtension = takeModule('submodule.js');β
const withoutExtension = takeModule('submodule');β
β
t.is(withExtension.name, 'submodule');β
t.is(withoutExtension.name, 'submodule');β
β
withExtension.value = 'mutated';β
β
t.is(withoutExtension.value, 'mutated');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return require(withName);β
}β
β
// The bundled code will run from test/helpers/util.jsβ
t.is(takeModule('../fixtures/function/dynamic-require-fallback/dep.js'), 'dep');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$1 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
const commonjsRegister = commonjsRegister$1;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-from-es-import/submodule.js", function (module, exports) {β
module.exports = 'submodule';β
β
});β
β
var submodule = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-from-es-import/submodule.js", "/$$rollup_base$$/fixtures/function/dynamic-require-from-es-import");β
β
t.is(submodule, 'submodule');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$3 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$2 = commonjsRegister$3;β
commonjsRegister$2("/$$rollup_base$$/fixtures/function/dynamic-require-globs/submodule1.js", function (module, exports) {β
module.exports = 'submodule1';β
β
});β
β
const commonjsRegister$1 = commonjsRegister$3;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-globs/submodule2.js", function (module, exports) {β
module.exports = 'submodule2';β
β
});β
β
const commonjsRegister = commonjsRegister$3;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-globs/extramodule1.js", function (module, exports) {β
module.exports = 'extramodule1';β
β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return commonjsRequire(`./${withName}`,"/$$rollup_base$$/fixtures/function/dynamic-require-globs");β
}β
β
t.is(takeModule('submodule1.js'), 'submodule1');β
t.is(takeModule('submodule2.js'), 'submodule2');β
t.is(takeModule('extramodule1.js'), 'extramodule1');β
t.throws(() => takeModule('extramodule2.js'), {β
message:β
'Could not dynamically require "./extramodule2.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'β
});β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$2 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
function commonjsRegisterOrShort$1 (path, to) {β
const resolvedPath = commonjsResolveImpl(path, null);β
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
} else {β
DYNAMIC_REQUIRE_SHORTS[path] = to;β
}β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$1 = commonjsRegister$2;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-instances/direct/index.js", function (module, exports) {β
module.exports = { name: 'direct', value: null };β
β
});β
β
const commonjsRegister = commonjsRegister$2;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-instances/package/main.js", function (module, exports) {β
module.exports = { name: 'package', value: null };β
β
});β
β
const commonjsRegisterOrShort = commonjsRegisterOrShort$1;β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-instances/direct", "/$$rollup_base$$/fixtures/function/dynamic-require-instances/direct/index.js");β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-instances/package", "/$$rollup_base$$/fixtures/function/dynamic-require-instances/package/main.js");β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return commonjsRequire(withName,"/$$rollup_base$$/fixtures/function/dynamic-require-instances");β
}β
β
takeModule('./direct').value = 'direct-instance';β
t.is(takeModule('./direct/index.js').value, 'direct-instance');β
t.is(commonjsRequire("./direct/index.js", "/$$rollup_base$$/fixtures/function/dynamic-require-instances").value, 'direct-instance');β
β
takeModule('./package').value = 'package-instance';β
t.is(takeModule('./package/main.js').value, 'package-instance');β
t.is(commonjsRequire("./package/main.js", "/$$rollup_base$$/fixtures/function/dynamic-require-instances").value, 'package-instance');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$1 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
var value = "present";β
var require$$1 = {β
value: valueβ
};β
β
const commonjsRegister = commonjsRegister$1;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-json/dynamic.json", function (module, exports) {β
module.exports = require$$1;β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return commonjsRequire(`./${withName}`,"/$$rollup_base$$/fixtures/function/dynamic-require-json");β
}β
β
t.deepEqual(takeModule('dynamic.json'), { value: 'present' });β
t.deepEqual(takeModule('dynamic'), { value: 'present' });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function commonjsRequire (path) {β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
var main = {};β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return commonjsRequire(withName);β
}β
β
t.throws(() => takeModule('./dep.js'), {β
message:β
'Could not dynamically require "./dep.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'β
});β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$3 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
function commonjsRegisterOrShort$1 (path, to) {β
const resolvedPath = commonjsResolveImpl(path, null);β
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
} else {β
DYNAMIC_REQUIRE_SHORTS[path] = to;β
}β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$2 = commonjsRegister$3;β
commonjsRegister$2("/$$rollup_base$$/fixtures/function/dynamic-require-package/entry.js", function (module, exports) {β
module.exports = 'same-directory';β
β
});β
β
const commonjsRegister$1 = commonjsRegister$3;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-package/sub/entry.js", function (module, exports) {β
module.exports = 'sub';β
β
});β
β
const commonjsRegister = commonjsRegister$3;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module/entry.js", function (module, exports) {β
module.exports = 'custom-module';β
β
});β
β
const commonjsRegisterOrShort = commonjsRegisterOrShort$1;β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-package", "/$$rollup_base$$/fixtures/function/dynamic-require-package/entry.js");β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-package/sub", "/$$rollup_base$$/fixtures/function/dynamic-require-package/sub/entry.js");β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module/entry.js");β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule$1(name) {β
return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-package/sub");β
}β
β
var sub = {β
parent: takeModule$1('..'),β
customModule: takeModule$1('custom-module')β
};β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(name) {β
return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-package");β
}β
β
t.is(takeModule('.'), 'same-directory');β
t.is(takeModule('./'), 'same-directory');β
t.is(takeModule('.//'), 'same-directory');β
β
t.is(takeModule('./sub'), 'sub');β
β
t.is(takeModule('custom-module'), 'custom-module');β
t.deepEqual(sub, { parent: 'same-directory', customModule: 'custom-module' });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'entry.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$2 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
function commonjsRegisterOrShort$1 (path, to) {β
const resolvedPath = commonjsResolveImpl(path, null);β
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
} else {β
DYNAMIC_REQUIRE_SHORTS[path] = to;β
}β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var entry = {};β
β
const commonjsRegister$1 = commonjsRegister$2;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/entry.js", function (module, exports) {β
module.exports = 'custom-module';β
β
});β
β
var main = "./entry.js";β
var require$$1 = {β
main: mainβ
};β
β
const commonjsRegister = commonjsRegister$2;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/package.json", function (module, exports) {β
module.exports = require$$1;β
});β
β
const commonjsRegisterOrShort = commonjsRegisterOrShort$1;β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/entry.js");β
β
t.is(commonjsRequire("custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/sub"), 'custom-module');β
β
module.exports = entry;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$2 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$1 = commonjsRegister$2;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths/sub/submodule.js", function (module, exports) {β
module.exports = 'submodule';β
β
});β
β
const commonjsRegister = commonjsRegister$2;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths/sub/subsub/subsubmodule.js", function (module, exports) {β
module.exports = 'subsubmodule';β
β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModuleWithDelimiter(name, delimiter) {β
return commonjsRequire(`.${delimiter}${name.replace(/=/g, delimiter)}`,"/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths");β
}β
β
t.is(takeModuleWithDelimiter('sub=submodule.js', '/'), 'submodule');β
t.is(takeModuleWithDelimiter('sub=subsub=subsubmodule.js', '/'), 'subsubmodule');β
t.is(takeModuleWithDelimiter('sub=submodule.js', '\\\\'), 'submodule');β
t.is(takeModuleWithDelimiter('sub=subsub=subsubmodule.js', '\\\\'), 'subsubmodule');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$3 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
function commonjsRegisterOrShort$1 (path, to) {β
const resolvedPath = commonjsResolveImpl(path, null);β
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
} else {β
DYNAMIC_REQUIRE_SHORTS[path] = to;β
}β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$2 = commonjsRegister$3;β
commonjsRegister$2("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/index.js", function (module, exports) {β
module.exports = 'same-directory';β
β
});β
β
const commonjsRegister$1 = commonjsRegister$3;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub/index.js", function (module, exports) {β
module.exports = 'sub';β
β
});β
β
const commonjsRegister = commonjsRegister$3;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module/index.js", function (module, exports) {β
module.exports = 'custom-module';β
β
});β
β
const commonjsRegisterOrShort = commonjsRegisterOrShort$1;β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index", "/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/index.js");β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub", "/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub/index.js");β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module/index.js");β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule$1(name) {β
return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub");β
}β
β
var sub = {β
parent: takeModule$1('..'),β
customModule: takeModule$1('custom-module')β
};β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(name) {β
return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index");β
}β
β
t.is(takeModule('.'), 'same-directory');β
t.is(takeModule('./'), 'same-directory');β
t.is(takeModule('.//'), 'same-directory');β
β
t.is(takeModule('./sub'), 'sub');β
β
t.is(takeModule('custom-module'), 'custom-module');β
t.deepEqual(sub, { parent: 'same-directory', customModule: 'custom-module' });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$2 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
function commonjsRegisterOrShort$1 (path, to) {β
const resolvedPath = commonjsResolveImpl(path, null);β
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
} else {β
DYNAMIC_REQUIRE_SHORTS[path] = to;β
}β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$1 = commonjsRegister$2;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module/index.js", function (module, exports) {β
module.exports = {β
foo: 'bar',β
};β
β
});β
β
const commonjsRegister = commonjsRegister$2;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2/index.js", function (module, exports) {β
module.exports = () => {β
return commonjsRequire.resolve('custom-module',"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2");β
};β
β
});β
β
const commonjsRegisterOrShort = commonjsRegisterOrShort$1;β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module/index.js");β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2", "/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2/index.js");β
β
t.is(β
commonjsRequire("custom-module2", "/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference")(),β
'/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module'β
);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$2 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
function commonjsRegisterOrShort$1 (path, to) {β
const resolvedPath = commonjsResolveImpl(path, null);β
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
} else {β
DYNAMIC_REQUIRE_SHORTS[path] = to;β
}β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister$1 = commonjsRegister$2;β
commonjsRegister$1("/$$rollup_base$$/fixtures/function/dynamic-require-root-circular/node_modules/custom-module/index.js", function (module, exports) {β
const circular = commonjsRequire("./lib/circular", "/$$rollup_base$$/fixtures/function/dynamic-require-root-circular/node_modules/custom-module");β
β
circular.extend1(module.exports);β
β
module.exports.get1 = function () {β
return 'all good';β
};β
β
circular.extend2(module.exports);β
β
});β
β
const commonjsRegister = commonjsRegister$2;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-root-circular/node_modules/custom-module/lib/circular.js", function (module, exports) {β
const lib = commonjsRequire("../", "/$$rollup_base$$/fixtures/function/dynamic-require-root-circular/node_modules/custom-module/lib");β
β
module.exports.extend1 = function (exports) {β
exports.get2 = function () {β
return 'indirect ref';β
};β
};β
β
module.exports.extend2 = function (exports) {β
exports.get3 = lib.get1;β
};β
β
});β
β
const commonjsRegisterOrShort = commonjsRegisterOrShort$1;β
commonjsRegisterOrShort("/$$rollup_base$$/fixtures/function/dynamic-require-root-circular/node_modules/custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-root-circular/node_modules/custom-module/index.js");β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
const custom = commonjsRequire("custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-root-circular");β
β
t.is(custom.get1(), 'all good');β
t.is(custom.get2(), 'indirect ref');β
t.is(custom.get3(), custom.get1());β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$1 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
return require(path);β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister = commonjsRegister$1;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-targets-fallback/dep1.js", function (module, exports) {β
module.exports = 'dep';β
β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return commonjsRequire(withName,"/$$rollup_base$$/fixtures/function/dynamic-require-targets-fallback");β
}β
β
t.is(takeModule('./dep1.js'), 'dep');β
// The bundled code will run from test/helpers/util.jsβ
t.is(takeModule('../fixtures/function/dynamic-require-targets-fallback/dep2.js'), 'dep');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
function commonjsRegister$1 (path, loader) {β
DYNAMIC_REQUIRE_LOADERS[path] = loader;β
}β
β
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);β
const DYNAMIC_REQUIRE_CACHE = Object.create(null);β
const DYNAMIC_REQUIRE_SHORTS = Object.create(null);β
const DEFAULT_PARENT_MODULE = {β
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []β
};β
const CHECKED_EXTENSIONS = ['', '.js', '.json'];β
β
function normalize (path) {β
path = path.replace(/\\\\/g, '/');β
const parts = path.split('/');β
const slashed = parts[0] === '';β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] === '.' || parts[i] === '') {β
parts.splice(i--, 1);β
}β
}β
for (let i = 1; i < parts.length; i++) {β
if (parts[i] !== '..') continue;β
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {β
parts.splice(--i, 2);β
i--;β
}β
}β
path = parts.join('/');β
if (slashed && path[0] !== '/')β
path = '/' + path;β
else if (path.length === 0)β
path = '.';β
return path;β
}β
β
function join () {β
if (arguments.length === 0)β
return '.';β
let joined;β
for (let i = 0; i < arguments.length; ++i) {β
let arg = arguments[i];β
if (arg.length > 0) {β
if (joined === undefined)β
joined = arg;β
elseβ
joined += '/' + arg;β
}β
}β
if (joined === undefined)β
return '.';β
β
return joined;β
}β
β
function isPossibleNodeModulesPath (modulePath) {β
let c0 = modulePath[0];β
if (c0 === '/' || c0 === '\\\\') return false;β
let c1 = modulePath[1], c2 = modulePath[2];β
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||β
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;β
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))β
return false;β
return true;β
}β
β
function dirname (path) {β
if (path.length === 0)β
return '.';β
β
let i = path.length - 1;β
while (i > 0) {β
const c = path.charCodeAt(i);β
if ((c === 47 || c === 92) && i !== path.length - 1)β
break;β
i--;β
}β
β
if (i > 0)β
return path.substr(0, i);β
β
if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)β
return path.charAt(0);β
β
return '.';β
}β
β
function commonjsResolveImpl (path, originalModuleDir, testCache) {β
const shouldTryNodeModules = isPossibleNodeModulesPath(path);β
path = normalize(path);β
let relPath;β
if (path[0] === '/') {β
originalModuleDir = '/';β
}β
while (true) {β
if (!shouldTryNodeModules) {β
relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;β
} else if (originalModuleDir) {β
relPath = normalize(originalModuleDir + '/node_modules/' + path);β
} else {β
relPath = normalize(join('node_modules', path));β
}β
β
if (relPath.endsWith('/..')) {β
break; // Travelled too far up, avoid infinite loopβ
}β
β
for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {β
const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];β
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_SHORTS[resolvedPath]) {β
return resolvedPath;β
}β
if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {β
return resolvedPath;β
}β
}β
if (!shouldTryNodeModules) break;β
const nextDir = normalize(originalModuleDir + '/..');β
if (nextDir === originalModuleDir) break;β
originalModuleDir = nextDir;β
}β
return null;β
}β
β
function commonjsResolve (path, originalModuleDir) {β
const resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
return resolvedPath;β
}β
return require.resolve(path);β
}β
β
function commonjsRequire (path, originalModuleDir) {β
let resolvedPath = commonjsResolveImpl(path, originalModuleDir);β
if (resolvedPath !== null) {β
let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];β
if (cachedModule) return cachedModule.exports;β
let shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];β
if (shortTo) {β
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];β
if (cachedModule)β
return cachedModule.exports;β
resolvedPath = commonjsResolveImpl(shortTo, null);β
}β
const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];β
if (loader) {β
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {β
id: resolvedPath,β
filename: resolvedPath,β
path: dirname(resolvedPath),β
exports: {},β
parent: DEFAULT_PARENT_MODULE,β
loaded: false,β
children: [],β
paths: [],β
require: function (path, base) {β
return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);β
}β
};β
try {β
loader.call(commonjsGlobal, cachedModule, cachedModule.exports);β
} catch (error) {β
delete DYNAMIC_REQUIRE_CACHE[resolvedPath];β
throw error;β
}β
cachedModule.loaded = true;β
return cachedModule.exports;β
} }β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;β
commonjsRequire.resolve = commonjsResolve;β
β
var main = {};β
β
const commonjsRegister = commonjsRegister$1;β
commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-targets-no-fallback/dep1.js", function (module, exports) {β
module.exports = 'dep';β
β
});β
β
/* eslint-disable import/no-dynamic-require, global-require */β
β
function takeModule(withName) {β
return commonjsRequire(withName,"/$$rollup_base$$/fixtures/function/dynamic-require-targets-no-fallback");β
}β
β
t.is(takeModule('./dep1.js'), 'dep');β
t.throws(() => takeModule('./dep2.js'), {β
message:β
'Could not dynamically require "./dep2.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'β
});β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
let root;β
β
if (typeof self !== 'undefined') {β
root = self;β
} else if (typeof window !== 'undefined') {β
root = window;β
} else if (typeof global !== 'undefined') {β
root = global;β
} else {β
root = module;β
}β
β
root.pollution = 'foo';β
β
const getGlobalPollution = () => 'foo';β
β
// this test makes sure that "submodule" is not wrapped in commonjsβ
β
t.is(getGlobalPollution(), global.pollution);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var require$$0 = require('external-cjs-exports');β
var require$$1 = require('external-cjs-module-exports');β
var require$$2 = require('external-esm-named');β
var require$$3 = require('external-esm-mixed');β
var require$$4 = require('external-esm-default');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);β
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);β
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);β
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);β
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);β
β
var main = {};β
β
const externalExports = require$$0__default["default"];β
const externalModuleExports = require$$1__default["default"];β
const externalNamed = require$$2__default["default"];β
const externalMixed = require$$3__default["default"];β
const externalDefault = require$$4__default["default"];β
β
t.deepEqual(externalExports, { foo: 'foo' }, 'external exports');β
t.deepEqual(externalModuleExports, 'bar', 'external module exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, 'bar', 'external mixed');β
t.deepEqual(externalDefault, 'bar', 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var require$$0 = require('external-cjs-exports');β
var require$$1 = require('external-cjs-module-exports');β
var require$$2 = require('external-esm-named');β
var require$$3 = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);β
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);β
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);β
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
var require$$4 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace);β
β
const externalExports = require$$0__default["default"];β
const externalModuleExports = require$$1__default["default"];β
const externalNamed = require$$2__default["default"];β
const externalMixed = require$$3__default["default"];β
const externalDefault = require$$4;β
β
t.deepEqual(externalExports, { foo: 'foo' }, 'external exports');β
t.deepEqual(externalModuleExports, 'bar', 'external module exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, 'bar', 'external mixed');β
t.deepEqual(externalDefault, { default: 'bar' }, 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var require$$0 = require('external-cjs-exports');β
var require$$1 = require('external-cjs-module-exports');β
var require$$2 = require('external-esm-named');β
var require$$3 = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);β
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);β
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);β
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
var require$$4 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace);β
β
const externalExports = require$$0__default["default"];β
const externalModuleExports = require$$1__default["default"];β
const externalNamed = require$$2__default["default"];β
const externalMixed = require$$3__default["default"];β
const externalDefault = require$$4;β
β
t.deepEqual(externalExports, { foo: 'foo' }, 'external exports');β
t.deepEqual(externalModuleExports, 'bar', 'external module exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, 'bar', 'external mixed');β
t.deepEqual(externalDefault, { default: 'bar' }, 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var externalEsmNamed = require('external-esm-named');β
var externalEsmMixed = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed);β
var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(externalEsmNamed__namespace);β
β
var require$$1 = /*@__PURE__*/getAugmentedNamespace(externalEsmMixed__namespace);β
β
var require$$2 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace);β
β
const externalNamed = require$$0;β
const externalMixed = require$$1;β
const externalDefault = require$$2;β
β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, { default: 'bar', foo: 'foo' }, 'external mixed');β
t.deepEqual(externalDefault, { default: 'bar' }, 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var require$$0 = require('external-cjs-exports');β
var require$$1 = require('external-cjs-module-exports');β
var require$$2 = require('external-esm-named');β
var require$$3 = require('external-esm-mixed');β
var require$$4 = require('external-esm-default');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);β
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);β
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);β
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);β
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);β
β
var main = {};β
β
const externalExports = require$$0__default["default"];β
const externalModuleExports = require$$1__default["default"];β
const externalNamed = require$$2__default["default"];β
const externalMixed = require$$3__default["default"];β
const externalDefault = require$$4__default["default"];β
β
t.deepEqual(externalExports, { foo: 'foo' }, 'external exports');β
t.deepEqual(externalModuleExports, 'bar', 'external module exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, 'bar', 'external mixed');β
t.deepEqual(externalDefault, 'bar', 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var require$$0 = 'default export';β
β
t.is(require$$0, 'default export');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var foo = {};β
β
foo.bar = 'BAR';β
foo.baz = 'BAZ';β
β
const { bar } = foo;β
const { baz } = foo;β
β
var main = bar + baz;β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var dep$1 = {exports: {}};β
β
(function (module, exports) {β
exports.foo = 'foo';β
module.exports = { replaced: true };β
exports.bar = 'bar';β
}(dep$1, dep$1.exports));β
β
const dep = dep$1.exports;β
β
t.deepEqual(dep, { replaced: true });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var other = require('./other.js');β
β
t.is(other, 'foo');β
`,
'other.js': `'use strict';β
β
var other = 'foo';β
β
module.exports = other;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var require$$0 = require('foo');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);β
β
const foo = require$$0__default["default"];β
β
var main = foo;β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
/* eslint-disable */β
var one = 1;β
β
var two = 2;β
β
var foo$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
one: one,β
two: twoβ
});β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(foo$1);β
β
const foo = require$$0;β
β
t.is(foo.one, 1);β
t.is(foo.two, 2);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
Object.defineProperty(exports, '__esModule', { value: true });β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
var encode = {};β
β
(function (exports) {β
exports.encodeURIComponent = function () {β
return encodeURIComponent(this.str);β
};β
β
// to ensure module is wrappedβ
commonjsGlobal.foo = exports;β
}(encode));β
β
/* eslint-disable */β
β
const foo = {β
str: 'test string',β
encodeURIComponent: encode.encodeURIComponentβ
};β
β
var encoded = foo.encodeURIComponent();β
β
exports.encoded = encoded;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
/* eslint-disable */β
β
function foo() {β
const global = {};β
global.modified = true;β
return global;β
}β
β
const notGlobal = foo();β
t.truthy(notGlobal.modified);β
t.truthy(!commonjsGlobal.modified);β
β
var main = {};β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var externalEsmNamed = require('external-esm-named');β
var externalEsmMixed = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed);β
var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
function getDefaultExportFromNamespaceIfNotNamed (n) {β
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;β
}β
β
var main = {};β
β
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(externalEsmNamed__namespace);β
β
var require$$1 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(externalEsmMixed__namespace);β
β
var require$$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(externalEsmDefault__namespace);β
β
const foo$1 = 'foo';β
β
var named = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo$1β
});β
β
const foo = 'foo';β
var mixed = 'bar';β
β
var mixed$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo,β
'default': mixedβ
});β
β
var require$$5 = 'bar';β
β
var none = /*#__PURE__*/Object.freeze({β
__proto__: nullβ
});β
β
const externalNamed = require$$0;β
const externalMixed = require$$1;β
const externalDefault = require$$2;β
β
const namedExports = named;β
const mixedExports = mixed$1;β
const defaultExport = require$$5;β
const noExports = none;β
β
t.deepEqual(namedExports, { foo: 'foo' }, 'named exports');β
t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports');β
t.deepEqual(defaultExport, 'bar', 'default export');β
t.deepEqual(noExports, {}, 'no exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed');β
t.deepEqual(externalDefault, 'bar', 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var externalEsmNamed = require('external-esm-named');β
var externalEsmMixed = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed);β
var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(externalEsmNamed__namespace);β
β
var require$$1 = /*@__PURE__*/getAugmentedNamespace(externalEsmMixed__namespace);β
β
var require$$2 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace);β
β
const foo$1 = 'foo';β
β
var named = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo$1β
});β
β
var require$$3 = /*@__PURE__*/getAugmentedNamespace(named);β
β
const foo = 'foo';β
var mixed = 'bar';β
β
var mixed$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo,β
'default': mixedβ
});β
β
var require$$4 = /*@__PURE__*/getAugmentedNamespace(mixed$1);β
β
var _default = 'bar';β
β
var _default$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
'default': _defaultβ
});β
β
var require$$5 = /*@__PURE__*/getAugmentedNamespace(_default$1);β
β
var none = /*#__PURE__*/Object.freeze({β
__proto__: nullβ
});β
β
var require$$6 = /*@__PURE__*/getAugmentedNamespace(none);β
β
const externalNamed = require$$0;β
const externalMixed = require$$1;β
const externalDefault = require$$2;β
β
const namedExports = require$$3;β
const mixedExports = require$$4;β
const defaultExport = require$$5;β
const noExports = require$$6;β
β
t.deepEqual(namedExports, { foo: 'foo' }, 'named exports');β
t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports');β
t.deepEqual(defaultExport, { default: 'bar' }, 'default export');β
t.deepEqual(noExports, {}, 'no exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed');β
t.deepEqual(externalDefault, { default: 'bar' }, 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
var dep_false_default_ = 'default';β
β
var dep_false_default_$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
'default': dep_false_default_β
});β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(dep_false_default_$1);β
β
var dep_false_mixed_ = 'default'; const named$4 = 'named';β
β
var dep_false_mixed_$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
'default': dep_false_mixed_,β
named: named$4β
});β
β
var require$$1 = /*@__PURE__*/getAugmentedNamespace(dep_false_mixed_$1);β
β
const named$3 = 'named';β
β
var dep_false_named_ = /*#__PURE__*/Object.freeze({β
__proto__: null,β
named: named$3β
});β
β
var require$$2 = /*@__PURE__*/getAugmentedNamespace(dep_false_named_);β
β
var require$$3 = 'default';β
β
var dep_auto_mixed_ = 'default'; const named$2 = 'named';β
β
var dep_auto_mixed_$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
'default': dep_auto_mixed_,β
named: named$2β
});β
β
const named$1 = 'named';β
β
var dep_auto_named_ = /*#__PURE__*/Object.freeze({β
__proto__: null,β
named: named$1β
});β
β
var require$$6 = 'default';β
β
var require$$7 = 'default';β
β
const named = 'named';β
β
var dep_preferred_named_ = /*#__PURE__*/Object.freeze({β
__proto__: null,β
named: namedβ
});β
β
var require$$9 = 'default';β
β
var require$$10 = 'default';β
β
const falseDefault = require$$0;β
const falseMixed = require$$1;β
const falseNamed = require$$2;β
β
const autoDefault = require$$3;β
const autoMixed = dep_auto_mixed_$1;β
const autoNamed = dep_auto_named_;β
β
const preferredDefault = require$$6;β
const preferredMixed = require$$7;β
const preferredNamed = dep_preferred_named_;β
β
const trueDefault = require$$9;β
const trueMixed = require$$10;β
β
t.deepEqual(falseDefault, { default: 'default' }, 'false default');β
t.deepEqual(falseMixed, { default: 'default', named: 'named' }, 'false mixed');β
t.deepEqual(falseNamed, { named: 'named' }, 'false named');β
β
t.deepEqual(autoDefault, 'default', 'auto default');β
t.deepEqual(autoMixed, { default: 'default', named: 'named' }, 'auto mixed');β
t.deepEqual(autoNamed, { named: 'named' }, 'auto named');β
β
t.deepEqual(preferredDefault, 'default', 'preferred default');β
t.deepEqual(preferredMixed, 'default', 'preferred mixed');β
t.deepEqual(preferredNamed, { named: 'named' }, 'preferred named');β
β
t.deepEqual(trueDefault, 'default', 'true default');β
t.deepEqual(trueMixed, 'default', 'true mixed');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main$1 = {};β
β
var require$$0$1 = 'other.js';β
β
var require$$1 = 'both.js';β
β
const other = require$$0$1;β
const both$1 = require$$1;β
β
t.deepEqual(other, 'other.js', 'other other');β
t.deepEqual(both$1, 'both.js', 'other both');β
β
var require$$0 = 'main.js';β
β
const main = require$$0;β
const both = require$$1;β
β
t.deepEqual(main, 'main.js', 'main main');β
t.deepEqual(both, 'both.js', 'main both');β
β
module.exports = main$1;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var externalEsmNamed = require('external-esm-named');β
var require$$1 = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed);β
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
function getDefaultExportFromNamespaceIfNotNamed (n) {β
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;β
}β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(externalEsmNamed__namespace);β
β
var require$$2 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace);β
β
const externalNamed = require$$0;β
const externalMixed = require$$1__default["default"];β
const externalDefault = require$$2;β
β
t.deepEqual(externalNamed, { foo: 'foo' }, 'named');β
t.deepEqual(externalMixed, 'bar', 'mixed');β
t.deepEqual(externalDefault, { default: 'bar' }, 'default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var externalEsmNamed = require('external-esm-named');β
var externalEsmMixed = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed);β
var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
var main = {};β
β
const foo$1 = 'foo';β
β
var named = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo$1β
});β
β
const foo = 'foo';β
var mixed = 'bar';β
β
var mixed$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo,β
'default': mixedβ
});β
β
var _default = 'bar';β
β
var _default$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
'default': _defaultβ
});β
β
var none = /*#__PURE__*/Object.freeze({β
__proto__: nullβ
});β
β
const externalNamed = externalEsmNamed__namespace;β
const externalMixed = externalEsmMixed__namespace;β
const externalDefault = externalEsmDefault__namespace;β
β
const namedExports = named;β
const mixedExports = mixed$1;β
const defaultExport = _default$1;β
const noExports = none;β
β
t.deepEqual(namedExports, { foo: 'foo' }, 'named exports');β
t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports');β
t.deepEqual(defaultExport, { default: 'bar' }, 'default export');β
t.deepEqual(noExports, {}, 'no exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed');β
t.deepEqual(externalDefault, { default: 'bar' }, 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var externalEsmNamed = require('external-esm-named');β
var externalEsmMixed = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed);β
var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
function getDefaultExportFromNamespaceIfPresent (n) {β
return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;β
}β
β
var main = {};β
β
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(externalEsmNamed__namespace);β
β
var require$$1 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(externalEsmMixed__namespace);β
β
var require$$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(externalEsmDefault__namespace);β
β
const foo = 'foo';β
β
var named = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: fooβ
});β
β
var require$$4 = 'bar';β
β
var require$$5 = 'bar';β
β
var none = /*#__PURE__*/Object.freeze({β
__proto__: nullβ
});β
β
const externalNamed = require$$0;β
const externalMixed = require$$1;β
const externalDefault = require$$2;β
β
const namedExports = named;β
const mixedExports = require$$4;β
const defaultExport = require$$5;β
const noExports = none;β
β
t.deepEqual(namedExports, { foo: 'foo' }, 'named exports');β
t.deepEqual(mixedExports, 'bar', 'mixed exports');β
t.deepEqual(defaultExport, 'bar', 'default export');β
t.deepEqual(noExports, {}, 'no exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, 'bar', 'external mixed');β
t.deepEqual(externalDefault, 'bar', 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var require$$0 = require('external-esm-named');β
var require$$1 = require('external-esm-mixed');β
var require$$2 = require('external-esm-default');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);β
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);β
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);β
β
var main = {};β
β
var require$$3 = 'bar';β
β
var require$$4 = 'bar';β
β
const externalNamed = require$$0__default["default"];β
const externalMixed = require$$1__default["default"];β
const externalDefault = require$$2__default["default"];β
β
const mixedExports = require$$3;β
const defaultExport = require$$4;β
β
t.deepEqual(mixedExports, 'bar', 'mixed exports');β
t.deepEqual(defaultExport, 'bar', 'default export');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, 'bar', 'external mixed');β
t.deepEqual(externalDefault, 'bar', 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var externalEsmNamed = require('external-esm-named');β
var externalEsmMixed = require('external-esm-mixed');β
var externalEsmDefault = require('external-esm-default');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
var externalEsmNamed__namespace = /*#__PURE__*/_interopNamespace(externalEsmNamed);β
var externalEsmMixed__namespace = /*#__PURE__*/_interopNamespace(externalEsmMixed);β
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespace(externalEsmDefault);β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(externalEsmNamed__namespace);β
β
var require$$1 = /*@__PURE__*/getAugmentedNamespace(externalEsmMixed__namespace);β
β
var require$$2 = /*@__PURE__*/getAugmentedNamespace(externalEsmDefault__namespace);β
β
const foo$1 = 'foo';β
β
var named = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo$1β
});β
β
var require$$3 = /*@__PURE__*/getAugmentedNamespace(named);β
β
const foo = 'foo';β
var mixed = 'bar';β
β
var mixed$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo,β
'default': mixedβ
});β
β
var require$$4 = /*@__PURE__*/getAugmentedNamespace(mixed$1);β
β
var _default = 'bar';β
β
var _default$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
'default': _defaultβ
});β
β
var require$$5 = /*@__PURE__*/getAugmentedNamespace(_default$1);β
β
var none = /*#__PURE__*/Object.freeze({β
__proto__: nullβ
});β
β
var require$$6 = /*@__PURE__*/getAugmentedNamespace(none);β
β
const externalNamed = require$$0;β
const externalMixed = require$$1;β
const externalDefault = require$$2;β
β
const namedExports = require$$3;β
const mixedExports = require$$4;β
const defaultExport = require$$5;β
const noExports = require$$6;β
β
t.deepEqual(namedExports, { foo: 'foo' }, 'named exports');β
t.deepEqual(mixedExports, { foo: 'foo', default: 'bar' }, 'mixed exports');β
t.deepEqual(defaultExport, { default: 'bar' }, 'default export');β
t.deepEqual(noExports, {}, 'no exports');β
t.deepEqual(externalNamed, { foo: 'foo' }, 'external named');β
t.deepEqual(externalMixed, { foo: 'foo', default: 'bar' }, 'external mixed');β
t.deepEqual(externalDefault, { default: 'bar' }, 'external default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
/* eslint-disable import/no-mutable-exports */β
let foo = 'foo';β
let bar = 'bar';β
β
function update(newFoo, newBar) {β
foo = newFoo;β
bar = newBar;β
}β
β
var lib$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
get default () { return foo; },β
get bar () { return bar; },β
update: updateβ
});β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(lib$1);β
β
/* eslint-disable */β
β
var lib = require$$0;β
β
function _interopDefault$1(e) {β
return e && e.__esModule ? e : { default: e };β
}β
β
var lib__default = /*#__PURE__*/_interopDefault$1(lib);β
t.is(lib__default['default'], 'foo');β
t.is(lib.bar, 'bar');β
β
lib.update('newFoo', 'newBar');β
t.is(lib__default['default'], 'newFoo');β
t.is(lib.bar, 'newBar');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var foo$1 = 42;β
β
const foo = foo$1;β
β
t.is(foo, 42);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var multiply = function (a, b) {β
return a * b;β
};β
β
var foo = 1;β
β
/* eslint-disable global-require */β
β
var main = function () {β
return multiply(2, foo);β
};β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getDefaultExportFromCjs (x) {β
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;β
}β
β
var other = {exports: {}};β
β
(function (module, exports) {β
exports.default = 42;β
β
addCompiledMarker(module.exports);β
β
function addCompiledMarker(exports) {β
// eslint-disable-next-line no-param-reassignβ
exports.__esModule = true;β
}β
}(other, other.exports));β
β
var foo = /*@__PURE__*/getDefaultExportFromCjs(other.exports);β
β
t.deepEqual(foo, 42);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var other = {exports: {}};β
β
(function (module) {β
addDefaultExport(module.exports);β
β
function addDefaultExport(exports) {β
// eslint-disable-next-line no-param-reassignβ
exports.default = 42;β
}β
}(other));β
β
var foo = other.exports;β
β
t.deepEqual(foo, { default: 42 });β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var other = {};β
β
other.foo = '__esModule';β
β
t.deepEqual(other, { foo: '__esModule' });β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var other = require('./other.js');β
β
var main = {};β
β
const foo = other;β
β
t.is(foo, 'foo');β
β
module.exports = main;β
`,
'other.js': `'use strict';β
β
var other = 'foo';β
β
module.exports = other;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
/*β
* This comment could be really important and should not be removedβ
*/β
β
var main = 'bar';β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var require$$0 = require('external-cjs-exports');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);β
β
var main = {};β
β
/*β
* This comment could be really important and should not be removedβ
*/β
β
const externalExports = require$$0__default["default"];β
β
t.is(externalExports.foo, 'foo');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
/*β
* This comment could be really important and should not be removedβ
*/β
β
(function (exports) {β
β
modifyExports(exports);β
β
function modifyExports(exported) {β
// eslint-disable-next-line no-param-reassignβ
exported.foo = 'bar';β
}β
}(main));β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var foo$1 = 21;β
β
const foo = foo$1;β
β
var main = foo * 2;β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var foo = {};β
β
Object.defineProperty(foo, '__esModule', { value: true });β
β
Object.defineProperty(foo, '__esModule', { value: true });β
β
var _default = foo.default = 'foo';β
β
t.deepEqual(_default, 'foo');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var a = 1;β
var b = 2;β
β
t.is(a, 1);β
t.is(b, 2);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var x = {exports: {}};β
β
if (typeof someUnknownGlobal !== 'undefined') {β
x.exports = { named: 'bar' };β
} else {β
x.exports = { named: 'foo' };β
}β
β
t.is(x.exports.named, 'foo');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var x = {exports: {}};β
β
(function (module) {β
window.addExport = (key, value) => {β
module.exports[key] = value;β
};β
}(x));β
β
t.is(x.exports.named, undefined);β
β
window.addExport('named', 'foo');β
β
t.is(x.exports.named, 'foo');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var x = {exports: {}};β
β
(function (module) {β
Object.defineProperty(module.exports, 'named', {β
enumerable: true,β
get: function get() {β
return 'foo';β
}β
});β
}(x));β
β
t.is(x.exports.named, 'foo');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var _export = {};β
β
_export.named = 2;β
β
var reexport = _export;β
β
t.is(reexport.named, 2);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var _export = {};β
β
_export.named = 2;β
β
const myModule = _export;β
β
var named = myModule.named;β
β
t.is(named, 2);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var x = {};β
β
x.named = 2;β
β
t.is(x.nonExisting, undefined);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getDefaultExportFromCjs (x) {β
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;β
}β
β
var foo$1 = {};β
β
(function (exports) {β
β
exports.default = 'foo';β
}(foo$1));β
β
var foo = /*@__PURE__*/getDefaultExportFromCjs(foo$1);β
β
t.deepEqual(foo, { default: 'foo' });β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getDefaultExportFromCjs (x) {β
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;β
}β
β
var foo$1 = {};β
β
(function (exports) {β
Object.defineProperty(exports, '__esModule', { value: true });β
β
{β
Object.defineProperty(exports, '__esModule', { value: true });β
}β
β
exports.default = 'foo';β
}(foo$1));β
β
var foo = /*@__PURE__*/getDefaultExportFromCjs(foo$1);β
β
t.deepEqual(foo, 'foo');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var dep1 = {};β
β
dep1.foo = 'first';β
β
reassignSomeExports$1();β
reassignSomeMoreExports$1();β
β
function reassignSomeExports$1() {β
dep1.foo = 'second';β
dep1.bar = 'first';β
}β
β
function reassignSomeMoreExports$1() {β
dep1.bar = 'second';β
}β
β
var bar;β
var foo = 'first';β
β
reassignSomeExports();β
reassignSomeMoreExports();β
β
function reassignSomeExports() {β
foo = 'second';β
bar = 'first';β
}β
β
function reassignSomeMoreExports() {β
bar = 'second';β
}β
β
t.is(dep1.foo, 'second');β
t.is(dep1.bar, 'second');β
t.is(foo, 'second');β
t.is(bar, 'second');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var dep1 = {β
foo: 'foo',β
update: () => (dep1 = { foo: 'bar' })β
};β
β
var dep1$1 = dep1;β
β
var dep2$1 = {exports: {}};β
β
dep2$1.exports.foo = 'foo';β
dep2$1.exports.update = () => (dep2$1.exports = { foo: 'bar' });β
β
var dep2 = dep2$1.exports;β
β
var dep3$1 = {exports: {}};β
β
(function (module, exports) {β
exports.foo = 'foo';β
module.exports.update = () => (module.exports = { foo: 'bar' });β
}(dep3$1, dep3$1.exports));β
β
var dep3 = dep3$1.exports;β
β
t.is(dep1$1.foo, 'foo', 'dep1');β
dep1$1.update();β
t.is(dep1$1.foo, 'foo', 'dep1 updated');β
β
t.is(dep2.foo, 'foo', 'dep2');β
dep2.update();β
t.is(dep2.foo, 'foo', 'dep2 updated');β
β
t.is(dep3.foo, 'foo', 'dep3');β
dep3.update();β
t.is(dep3.foo, 'foo', 'dep3 updated');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var dep$1 = 42;β
β
const dep = dep$1;β
β
t.is(dep, 42);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main$1 = {};β
β
var dep$1 = {};β
β
dep$1.foo = 'bar';β
β
const dep = dep$1;β
β
t.is(dep.foo, 'bar');β
β
var main = main$1;β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var dep1$1 = {exports: {}};β
β
if (reassignFirstModuleExports) {β
dep1$1.exports = 'reassigned';β
}β
β
var dep2$1 = {exports: {}};β
β
if (reassignSecondModuleExports) {β
dep2$1.exports = 'reassigned';β
}β
β
const dep1 = dep1$1.exports;β
const dep2 = dep2$1.exports;β
β
t.is(dep1, 'reassigned');β
t.deepEqual(dep2, {});β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var shared$2 = {β
fooLoaded: falseβ
};β
β
const shared$1 = shared$2;β
β
// Mutate the shared moduleβ
shared$1.fooLoaded = true;β
β
const shared = shared$2;β
β
var bar = shared.fooLoaded;β
β
const fooLoaded = bar;β
β
t.truthy(fooLoaded);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'bar-imported-49e0dbcf.js': `'use strict';β
β
var barImported = 'imported';β
β
exports["default"] = barImported;β
`,
'main.js': `'use strict';β
β
var foo = 'imported';β
β
var requiring = {};β
β
var fooRequired = 'required';β
β
requiring.foo = fooRequired;β
β
requiring.barPromise = Promise.resolve().then(function () { return require('./bar-imported-49e0dbcf.js'); });β
β
t.is(foo, 'imported');β
t.is(requiring.foo, 'required');β
β
var main = Promise.all([Promise.resolve().then(function () { return require('./bar-imported-49e0dbcf.js'); }), requiring.barPromise]);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsBar = {};β
β
/* eslint-disable no-underscore-dangle */β
β
function Bar$1() {β
this.x = 42;β
}β
β
commonjsBar.__esModule = true;β
commonjsBar.default = Bar$1;β
β
/* eslint-disable no-underscore-dangle */β
β
const Bar = commonjsBar;β
var Bar_1 = Bar.default;β
β
t.is(new Bar_1().x, 42);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var identifier$1 = {};β
β
(function (exports) {β
exports = 'foo';β
t.is(exports, 'foo');β
}(identifier$1));β
β
var property$1 = {};β
β
(function (exports) {β
({ foo: exports } = { foo: 'foo' });β
t.is(exports, 'foo');β
}(property$1));β
β
var arrayPattern$1 = {};β
β
(function (exports) {β
[exports] = ['foo'];β
t.is(exports, 'foo');β
}(arrayPattern$1));β
β
var assignmentPattern$1 = {};β
β
(function (exports) {β
({ exports = 'foo' } = {});β
t.is(exports, 'foo');β
}(assignmentPattern$1));β
β
const identifier = identifier$1;β
const property = property$1;β
const arrayPattern = arrayPattern$1;β
const assignmentPattern = assignmentPattern$1;β
β
t.deepEqual(identifier, {});β
t.deepEqual(property, {});β
t.deepEqual(arrayPattern, {});β
t.deepEqual(assignmentPattern, {});β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var identifier$1 = {exports: {}};β
β
(function (module) {β
// eslint-disable-next-line no-global-assignβ
module = 'foo';β
t.is(module, 'foo');β
}(identifier$1));β
β
var property$1 = {exports: {}};β
β
(function (module) {β
// eslint-disable-next-line no-global-assignβ
({ foo: module } = { foo: 'foo' });β
t.is(module, 'foo');β
}(property$1));β
β
var arrayPattern$1 = {exports: {}};β
β
(function (module) {β
// eslint-disable-next-line no-global-assignβ
[module] = ['foo'];β
t.is(module, 'foo');β
}(arrayPattern$1));β
β
var assignmentPattern$1 = {exports: {}};β
β
(function (module) {β
// eslint-disable-next-line no-global-assignβ
({ module = 'foo' } = {});β
t.is(module, 'foo');β
}(assignmentPattern$1));β
β
const identifier = identifier$1.exports;β
const property = property$1.exports;β
const arrayPattern = arrayPattern$1.exports;β
const assignmentPattern = assignmentPattern$1.exports;β
β
t.deepEqual(identifier, {});β
t.deepEqual(property, {});β
t.deepEqual(arrayPattern, {});β
t.deepEqual(assignmentPattern, {});β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var dep$1 = {exports: {}};β
β
const exported = {};β
dep$1.exports = exported;β
dep$1.exports.foo = 'foo';β
β
t.deepEqual(exported, { foo: 'foo' });β
β
const dep = dep$1.exports;β
β
t.deepEqual(dep, { foo: 'foo' });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
function foo$1() {}β
foo$1.something = false;β
β
var foo_1 = foo$1;β
β
let foo = foo_1;β
β
if (!foo.something) {β
foo = function somethingElse() {};β
foo.something = true;β
}β
β
t.truthy(foo.something);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
const foo = 'foo';β
var other = 'bar';β
β
var other$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo,β
'default': otherβ
});β
β
var dep$1 = 'default';β
β
var dep$2 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
'default': dep$1,β
ns: other$1β
});β
β
const dep = dep$2;β
β
t.deepEqual(dep, { default: 'default', ns: { default: 'bar', foo: 'foo' } });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
const foo = 'foo';β
β
var dep$1 = 'default';β
β
var dep$2 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
'default': dep$1,β
foo: fooβ
});β
β
const dep = dep$2;β
β
t.deepEqual(dep, { default: 'default', foo: 'foo' });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
const foo = 'foo';β
var other = 'bar';β
β
var other$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: foo,β
'default': otherβ
});β
β
const dep = other$1;β
β
t.deepEqual(dep, { default: 'bar', foo: 'foo' });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
const foo = 'foo';β
β
var dep$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
foo: fooβ
});β
β
const dep = dep$1;β
β
t.deepEqual(dep, { foo: 'foo' });β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var dep$1 = {β
foo: 'foo',β
update: () => (dep$1 = { foo: 'bar' })β
};β
β
const dep = dep$1;β
β
t.is(dep.foo, 'foo');β
β
dep.update();β
β
t.is(dep.foo, 'foo');β
t.is(dep$1.foo, 'bar');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
const result = 'second';β
β
var second = /*#__PURE__*/Object.freeze({β
__proto__: null,β
result: resultβ
});β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(second);β
β
t.is(require$$0.result, 'second');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var main = {};β
β
const result = 'second';β
β
var second = /*#__PURE__*/Object.freeze({β
__proto__: null,β
result: resultβ
});β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(second);β
β
t.is(require$$0.result, 'second');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var foo$1 = 'foo';β
β
const foo = foo$1;β
β
t.is(foo, 'foo');β
β
{β
// eslint-disable-next-line no-shadowβ
const foo = 'wrong';β
// eslint-disable-next-line global-requireβ
const bar = foo$1;β
t.is(foo, 'wrong');β
t.is(bar, 'foo');β
}β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function foo(require) {β
require('not-an-actual-require-statement');β
}β
β
let result;β
β
foo((msg) => {β
result = msg;β
});β
β
t.is(result, 'not-an-actual-require-statement');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
commonjsGlobal.b = 2;β
var b = 'b';β
β
/* eslint-disable */β
β
var main = b ;β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};β
β
var main = {};β
β
var foo$1 = function augmentThis() {β
this.x = 'x';β
};β
β
commonjsGlobal.y = 'y';β
β
const foo = foo$1;β
β
const obj = {};β
foo.call(obj);β
β
t.is(obj.x, 'x');β
t.is(commonjsGlobal.y, 'y');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var dep1$1 = 'original';β
if (reassignFirstModuleExports) {β
dep1$1 = 'reassigned';β
}β
β
var dep2$1 = 'original';β
if (reassignSecondModuleExports) {β
dep2$1 = 'reassigned';β
}β
β
if (reassignFirstModuleExports) {β
dep3$1 = 'reassigned';β
}β
var dep3$1 = 'final';β
β
if (reassignSecondModuleExports) {β
dep4$1 = 'reassigned';β
}β
var dep4$1 = 'final';β
β
const dep1 = dep1$1;β
const dep2 = dep2$1;β
const dep3 = dep3$1;β
const dep4 = dep4$1;β
β
t.is(dep1, 'reassigned');β
t.is(dep2, 'original');β
t.is(dep3, 'final');β
t.is(dep4, 'final');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
/* eslint-disable */β
β
var main = 'foo';β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var foo$1 = {exports: {}};β
β
(function (module) {β
β
module.exports = 'bar';β
{β
return;β
}β
}(foo$1));β
β
const foo = foo$1.exports;β
β
var main = foo;β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var foo$1 = 42;β
β
const foo = foo$1;β
β
t.is(foo, 42);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getAugmentedNamespace(n) {β
if (n.__esModule) return n;β
var a = Object.defineProperty({}, '__esModule', {value: true});β
Object.keys(n).forEach(function (k) {β
var d = Object.getOwnPropertyDescriptor(n, k);β
Object.defineProperty(a, k, d.get ? d : {β
enumerable: true,β
get: function () {β
return n[k];β
}β
});β
});β
return a;β
}β
β
var other$1 = 'other';β
β
const other = other$1;β
β
var dep$1 = /*#__PURE__*/Object.freeze({β
__proto__: null,β
other: otherβ
});β
β
var require$$0 = /*@__PURE__*/getAugmentedNamespace(dep$1);β
β
const dep = require$$0;β
β
t.is(other, 'other');β
t.deepEqual(dep, { other: 'other' });β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var external = require('external-esm-default');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
var external__default = /*#__PURE__*/_interopDefaultLegacy(external);β
β
var dep = {};β
β
Object.defineProperty(dep, '__esModule', { value: true });β
var _default = dep.default = 'default';β
β
t.is(_default, 'default');β
t.is(external__default["default"], 'bar');β
`,
}
Snapshot 1
{
'entry-942c2db3.js': `'use strict';β
β
function _mergeNamespaces(n, m) {β
m.forEach(function (e) {β
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {β
if (k !== 'default' && !(k in n)) {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
});β
return Object.freeze(n);β
}β
β
var entry$1 = {};β
β
Object.defineProperty(entry$1, '__esModule', { value: true });β
var _default = entry$1.default = 'default';β
β
var entry = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({β
__proto__: null,β
'default': _defaultβ
}, [entry$1]));β
β
exports._default = _default;β
exports.entry = entry;β
`,
'entry.js': `'use strict';β
β
var entry = require('./entry-942c2db3.js');β
β
β
β
module.exports = entry._default;β
`,
'main.js': `'use strict';β
β
var entry = require('./entry-942c2db3.js');β
β
t.deepEqual(entry.entry, { default: 'default' });β
`,
}
Snapshot 1
{
'entry-51172103.js': `'use strict';β
β
function _mergeNamespaces(n, m) {β
m.forEach(function (e) {β
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {β
if (k !== 'default' && !(k in n)) {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
});β
return Object.freeze(n);β
}β
β
var entry$1 = {};β
β
Object.defineProperty(entry$1, '__esModule', { value: true });β
var _default = entry$1.default = 'default';β
var named = entry$1.named = 'named';β
β
var entry = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({β
__proto__: null,β
named: named,β
'default': _defaultβ
}, [entry$1]));β
β
exports._default = _default;β
exports.entry = entry;β
exports.named = named;β
`,
'entry.js': `'use strict';β
β
Object.defineProperty(exports, '__esModule', { value: true });β
β
var entry = require('./entry-51172103.js');β
β
β
β
exports["default"] = entry._default;β
exports.named = entry.named;β
`,
'main.js': `'use strict';β
β
var entry = require('./entry-51172103.js');β
β
t.deepEqual(entry.entry, { default: 'default', named: 'named' });β
`,
}
Snapshot 1
{
'entry.js': `'use strict';β
β
Object.defineProperty(exports, '__esModule', { value: true });β
β
var entry = require('./generated-entry.js');β
β
β
β
exports["default"] = entry.entry$1;β
exports.named = entry.named;β
`,
'generated-entry.js': `'use strict';β
β
function _mergeNamespaces(n, m) {β
m.forEach(function (e) {β
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {β
if (k !== 'default' && !(k in n)) {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
});β
return Object.freeze(n);β
}β
β
var entry$1 = {};β
β
Object.defineProperty(entry$1, '__esModule', { value: true });β
var named = entry$1.named = 'named';β
β
var entry = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({β
__proto__: null,β
named: named,β
'default': entry$1β
}, [entry$1]));β
β
exports.entry = entry;β
exports.entry$1 = entry$1;β
exports.named = named;β
`,
'main.js': `'use strict';β
β
var entry = require('./generated-entry.js');β
β
t.deepEqual(entry.entry, {β
default: {β
named: 'named'β
},β
named: 'named'β
});β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var external = require('external-esm-mixed');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
var external__default = /*#__PURE__*/_interopDefaultLegacy(external);β
β
var dep = {};β
β
Object.defineProperty(dep, '__esModule', { value: true });β
var named = dep.named = 'named';β
var _default = dep.default = 'default';β
β
t.is(_default, 'default');β
t.is(named, 'named');β
t.is(external__default["default"], 'bar');β
t.is(external.foo, 'foo');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var externalEsmNamed = require('external-esm-named');β
β
var dep = {};β
β
Object.defineProperty(dep, '__esModule', { value: true });β
var named = dep.named = 'named';β
β
t.is(named, 'named');β
t.is(externalEsmNamed.foo, 'foo');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var external = require('external-esm-default');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
function _mergeNamespaces(n, m) {β
m.forEach(function (e) {β
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {β
if (k !== 'default' && !(k in n)) {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
});β
return Object.freeze(n);β
}β
β
var external__namespace = /*#__PURE__*/_interopNamespace(external);β
β
var dep$1 = {};β
β
Object.defineProperty(dep$1, '__esModule', { value: true });β
var _default = dep$1.default = 'default';β
β
var dep = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({β
__proto__: null,β
'default': _defaultβ
}, [dep$1]));β
β
t.deepEqual(dep, {β
default: 'default'β
});β
β
t.deepEqual(external__namespace, {β
default: 'bar'β
});β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var external = require('external-esm-mixed');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
function _mergeNamespaces(n, m) {β
m.forEach(function (e) {β
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {β
if (k !== 'default' && !(k in n)) {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
});β
return Object.freeze(n);β
}β
β
var external__namespace = /*#__PURE__*/_interopNamespace(external);β
β
var dep$1 = {};β
β
Object.defineProperty(dep$1, '__esModule', { value: true });β
var named = dep$1.named = 'named';β
var _default = dep$1.default = 'default';β
β
var dep = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({β
__proto__: null,β
named: named,β
'default': _defaultβ
}, [dep$1]));β
β
t.deepEqual(dep, {β
default: 'default',β
named: 'named'β
});β
β
t.deepEqual(external__namespace, {β
default: 'bar',β
foo: 'foo'β
});β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var external = require('external-esm-named');β
β
function _interopNamespace(e) {β
if (e && e.__esModule) return e;β
var n = Object.create(null);β
if (e) {β
Object.keys(e).forEach(function (k) {β
if (k !== 'default') {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
}β
n["default"] = e;β
return Object.freeze(n);β
}β
β
function _mergeNamespaces(n, m) {β
m.forEach(function (e) {β
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {β
if (k !== 'default' && !(k in n)) {β
var d = Object.getOwnPropertyDescriptor(e, k);β
Object.defineProperty(n, k, d.get ? d : {β
enumerable: true,β
get: function () { return e[k]; }β
});β
}β
});β
});β
return Object.freeze(n);β
}β
β
var external__namespace = /*#__PURE__*/_interopNamespace(external);β
β
var dep$1 = {};β
β
Object.defineProperty(dep$1, '__esModule', { value: true });β
var named = dep$1.named = 'named';β
β
var dep = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({β
__proto__: null,β
named: named,β
'default': dep$1β
}, [dep$1]));β
β
t.deepEqual(dep, {β
default: {β
named: 'named'β
},β
named: 'named'β
});β
β
t.deepEqual(external__namespace, {β
foo: 'foo'β
});β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getDefaultExportFromCjs (x) {β
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;β
}β
β
var dep$1 = {exports: {}};β
β
Object.defineProperty(dep$1.exports, '__esModule', { value: true });β
β
if (globalValue) {β
dep$1.exports = 'first';β
} else {β
dep$1.exports = 'second';β
}β
β
var dep = /*@__PURE__*/getDefaultExportFromCjs(dep$1.exports);β
β
t.is(dep, 'first');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function getDefaultExportFromCjs (x) {β
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;β
}β
β
var dep$1 = {exports: {}};β
β
if (globalValue) {β
dep$1.exports = { default: 'first' };β
} else {β
dep$1.exports = { default: 'second' };β
}β
β
Object.defineProperty(dep$1.exports, '__esModule', { value: true });β
β
var dep = /*@__PURE__*/getDefaultExportFromCjs(dep$1.exports);β
β
t.is(dep, 'first');β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var dep$1 = {};β
β
Object.defineProperty(dep$1, '__esModule', { value: true });β
dep$1.named = 'named';β
dep$1.default = 'default';β
β
const dep = dep$1;β
β
t.deepEqual(dep, {β
default: 'default',β
named: 'named'β
});β
β
// eslint-disable-next-line no-prototype-builtinsβ
t.is(dep.hasOwnProperty('named'), true);β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var main = {};β
β
var dep$1 = {};β
β
Object.defineProperty(dep$1, '__esModule', { value: true });β
dep$1.default = 'default';β
β
const dep = dep$1;β
β
function _interopDefault$1(e) {β
return e && e.__esModule ? e : { default: e };β
}β
β
t.is(dep.__esModule, true);β
const dep__default = /* #__PURE__*/ _interopDefault$1(dep);β
t.is(dep__default.default, 'default');β
β
module.exports = main;β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
/* eslint-disable global-require */β
β
try {β
require('uninstalled-external-module');β
} catch (ignored) {β
/* ignore */β
}β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
/* eslint-disable global-require */β
β
try {β
require('uninstalled-external-module');β
} catch (ignored) {β
/* ignore */β
}β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
/* eslint-disable global-require */β
β
try {β
require('uninstalled-external-module');β
} catch (ignored) {β
/* ignore */β
}β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function commonjsRequire (path) {β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
var foo$1 = {exports: {}};β
β
if (typeof commonjsRequire === 'function' && commonjsRequire) {β
foo$1.exports = 1;β
} else {β
foo$1.exports = 2;β
}β
β
var foo = foo$1.exports;β
β
t.is(foo, 1);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
function commonjsRequire (path) {β
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');β
}β
β
var foo$1 = {exports: {}};β
β
if (typeof commonjsRequire === 'function' && commonjsRequire) {β
foo$1.exports = 1;β
} else {β
foo$1.exports = 2;β
}β
β
var foo = foo$1.exports;β
β
t.is(foo, 1);β
`,
}
Snapshot 1
{
'main.js': `'use strict';β
β
var require$$0 = require('path');β
β
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }β
β
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);β
β
var main = {};β
β
const path = require$$0__default["default"];β
β
t.is(typeof path.resolve, 'function');β
β
module.exports = main;β
`,
}