`${unused.slice(0,-1).map(name=>`'${name}'`).join(', ')} and '${unused.pop()}' are`;
this.onwarn(`${names} imported from external module '${module.id}' but never used`);
this.warn({
code:'UNUSED_EXTERNAL_IMPORT',
message:`${names} imported from external module '${module.id}' but never used`
});
});
this.orderedModules=this.sort();
@ -309,7 +312,10 @@ export default class Bundle {
keys(exportAllModule.exportsAll).forEach(name=>{
if(nameinmodule.exportsAll){
this.onwarn(`Conflicting namespaces: ${module.id} re-exports '${name}' from both ${module.exportsAll[name]} (will be ignored) and ${exportAllModule.exportsAll[name]}.`);
this.warn({
code:'NAMESPACE_CONFLICT',
message:`Conflicting namespaces: ${relativeId(module.id)} re-exports '${name}' from both ${relativeId(module.exportsAll[name])} (will be ignored) and ${relativeId(exportAllModule.exportsAll[name])}`
if(isRelative(source))thrownewError(`Could not resolve '${source}' from ${module.id}`);
this.onwarn(`'${source}' is imported by ${relativeId(module.id)}, but could not be resolved – treating it as an external dependency. For help see https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency`);
this.warn({
code:'UNRESOLVED_IMPORT',
message:`'${source}' is imported by ${relativeId(module.id)}, but could not be resolved – treating it as an external dependency`,
this.module.bundle.onwarn(`${relativeId(this.module.id)} (${line}:${column}) Ambiguous default export (is a call expression, but looks like a function declaration). See https://github.com/rollup/rollup/wiki/Troubleshooting#ambiguous-default-export`);
this.module.warn({
code:'AMBIGUOUS_DEFAULT_EXPORT',
message:`Ambiguous default export (is a call expression, but looks like a function declaration)`,
this.module.bundle.onwarn(`${relativeId(this.module.id)} (${line}:${column}) '${part.name}' is not exported by '${relativeId(exporterId)}'. See https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module`);
this.module.warn({
code:'MISSING_EXPORT',
message:`'${part.name}' is not exported by '${relativeId(exporterId)}'`,
constwarning=`The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten. See https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined for more information`;
`modules (${externalBuiltins.slice(0,-1).map(name=>`'${name}'`).join(', ')} and '${externalBuiltins.pop()}')`;
bundle.onwarn(`Creating a browser bundle that depends on Node.js built-in ${detail}. You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins`);
bundle.warn({
code:'MISSING_NODE_BUILTINS',
message:`Creating a browser bundle that depends on Node.js built-in ${detail}. You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins`
onwarn(`Sourcemap is likely to be incorrect: a plugin${map.plugin?` ('${map.plugin}')`:``} was used to transform files, but didn't generate a sourcemap for the transformation. Consult https://github.com/rollup/rollup/wiki/Troubleshooting and the plugin documentation for more information`);
bundle.warn({
code:'SOURCEMAP_BROKEN',
message:`Sourcemap is likely to be incorrect: a plugin${map.plugin?` ('${map.plugin}')`:``} was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`,
bundle.onwarn(`Using named and default exports together. Consumers of your bundle will have to use ${moduleName||'bundle'}['default'] to access the default export, which may not be what you want. Use \`exports: 'named'\` to disable this warning. See https://github.com/rollup/rollup/wiki/JavaScript-API#exports for more information`);
bundle.warn({
code:'MIXED_EXPORTS',
message:`Using named and default exports together. Consumers of your bundle will have to use ${moduleName||'bundle'}['default'] to access the default export, which may not be what you want. Use \`exports: 'named'\` to disable this warning`,
`'path' is imported by main.js, but could not be resolved – treating it as an external dependency. For help see https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency`
]);
},
warnings:[
{
code:'UNRESOLVED_IMPORT',
message:`'path' is imported by main.js, but could not be resolved – treating it as an external dependency`,
`'path' is imported by main.js, but could not be resolved – treating it as an external dependency. For help see https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency`
]);
},
warnings:[
{
code:'UNRESOLVED_IMPORT',
message:`'path' is imported by main.js, but could not be resolved – treating it as an external dependency`,
@ -2,11 +2,13 @@ var assert = require( 'assert' );
module.exports={
description:'does not hang on missing module (#53)',
warnings:warnings=>{
assert.deepEqual(warnings,[
`'unlessYouCreatedThisFileForSomeReason' is imported by main.js, but could not be resolved – treating it as an external dependency. For help see https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency`
]);
},
warnings:[
{
code:'UNRESOLVED_IMPORT',
message:`'unlessYouCreatedThisFileForSomeReason' is imported by main.js, but could not be resolved – treating it as an external dependency`,
assert.equal(msg,`main.js (3:21) 'foo' is not exported by 'empty.js'. See https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module`);
`'external' is imported by main.js, but could not be resolved – treating it as an external dependency. For help see https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency`,
`'unused', 'notused' and 'neverused' are imported from external module 'external' but never used`,
`Generated an empty bundle`
]);
}
warnings:[
{
code:'UNRESOLVED_IMPORT',
message:`'external' is imported by main.js, but could not be resolved – treating it as an external dependency`,
description:'uses original name of default export function (#1011)',
warnings:warnings=>{
assert.deepEqual(warnings,[
'foo.js (1:15) Ambiguous default export (is a call expression, but looks like a function declaration). See https://github.com/rollup/rollup/wiki/Troubleshooting#ambiguous-default-export'
]);
}
warnings:[
{
code:'AMBIGUOUS_DEFAULT_EXPORT',
message:`Ambiguous default export (is a call expression, but looks like a function declaration)`,
description:'warns if default and named exports are used in auto mode',
warnings:function(warnings){
assert.deepEqual(warnings,[
'Using named and default exports together. Consumers of your bundle will have to use bundle[\'default\'] to access the default export, which may not be what you want. Use `exports: \'named\'` to disable this warning. See https://github.com/rollup/rollup/wiki/JavaScript-API#exports for more information'
]);
}
warnings:[
{
code:'MIXED_EXPORTS',
message:`Using named and default exports together. Consumers of your bundle will have to use bundle['default'] to access the default export, which may not be what you want. Use \`exports: 'named'\` to disable this warning`,
`main.js (3:1) The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten. See https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined for more information`
]);
},
warnings:[
{
code:'THIS_IS_UNDEFINED',
message:`The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`,
description:'preserves sourcemap chains when transforming',
before:()=>warnings=[],// reset
options:{
plugins:[
{
@ -13,14 +8,13 @@ module.exports = {
returncode;
}
}
],
onwarn(msg){
warnings.push(msg);
}
]
},
test:()=>{
assert.deepEqual(warnings,[
`Sourcemap is likely to be incorrect: a plugin ('fake plugin') was used to transform files, but didn't generate a sourcemap for the transformation. Consult https://github.com/rollup/rollup/wiki/Troubleshooting and the plugin documentation for more information`
]);
}
warnings:[
{
code:`SOURCEMAP_BROKEN`,
message:`Sourcemap is likely to be incorrect: a plugin ('fake plugin') was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`,
@ -401,9 +423,16 @@ describe( 'rollup', function () {
bundle.write(options);
if(config.before)config.before();
constresult=bundle.generate(options);
config.test(result.code,result.map);
if(config.test){
const{code,map}=bundle.generate(options);
config.test(code,map);
}
if(config.warnings){
compareWarnings(warnings,config.warnings);
}elseif(warnings.length){
thrownewError(`Unexpected warnings`);
}
});
});
});
@ -747,11 +776,9 @@ describe( 'rollup', function () {
moduleName:'myBundle'
});
assert.deepEqual(warnings,[
`'util' is imported by entry, but could not be resolved – treating it as an external dependency. For help see https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency`,
`Creating a browser bundle that depends on Node.js built-in module ('util'). You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins`,
`No name was provided for external module 'util' in options.globals – guessing 'util'`
assert.equal(relevantWarnings[0].message,`Creating a browser bundle that depends on Node.js built-in module ('util'). You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins`);