-
Notifications
You must be signed in to change notification settings - Fork 86
Rollup's external
option only sufficient to suppress import
, skip
additionally required to suppress require
#72
Comments
external
option only applies to import
statements, skip
required to suppress require
external
option only sufficient to suppress import
, skip
additionally required to suppress require
Just external does not do it for named import either: import { set } from 'lodash'
export { set } bundles |
I assume this was solved by #90. If not, leave a comment |
I think that #90 did not solve the issue but rather removed the workaround, because it is no longer possible to specify |
Whoever fixes this, please note the following quirk in the previous behavior of Consider this setup using // index.js
import {doSomethingWithHandlebars} from './StringUtils.js';
console.log(doSomethingWithHandlebars()); // StringUtils.js
var Handlebars = require('handlebars/runtime');
module.exports.doSomethingWithHandlebars = function() {
Handlebars.madeUpFunction();
}; // package.json
{
"dependencies": {
"rollup": "^0.45.2",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^2.0.0"
},
"dependencies": {
"handlebars": "^4.0.10",
}
} // rollup.config.js
import nodeResolve from 'rollup-plugin-node-resolve';
import commonJS from 'rollup-plugin-commonjs';
export default {
entry: 'index.js',
external: ['handlebars/runtime'],
plugins: [
nodeResolve({
skip: ['handlebars/runtime']
}),
commonJS(),
],
targets: [{
format: 'iife',
dest: 'bundle.js'
}]
}; The above Instead you have to do But hopefully the fix to this issue will allow |
External doesn't work at all for me. It always pulls in a relative path if it is found in node_modules. |
any updates ? |
what happened ? |
any updates? |
I checked it with latest versions, all works fine, with commonjs module and with es6 module. Repro here: https://github.com/mecurc/72-rollup-resolve Can be closed now. |
UPDATE 07.13.2017: This issue is written as if we still had the
skip
option from version 2.x. As this comment notes, 3.x does not fix the problem with this module andexternal
but rather removes the workaround of specifyingskip
. :(As per @Rich-Harris's comment here, this plugin will automatically skip modules marked as
external
(without the user having to specify theskip
option). But, my testing reveals that the plugin will only do this if the module is imported using animport
statement, not via arequire
statement—in the latter case, you must also specifyskip
.Example:
The following Rollup configuration will not prevent Underscore from being bundled:
—I must also specify
nodeResolve({skip: ['underscore']})
. (skip
alone is not sufficient—if I don't defineexternal
, Rollup prints a "Treating 'underscore' as external dependency" warning.)However, if I make
StringUtils
an ES6 module:Then
external: ['underscore']
is sufficient.Is this expected? It would be nice if
external
was sufficient for both ES6 and CommonJS modules.It's also kind of weird that I need both
skip
andexternal
in the CommonJS case. EDIT: Upon re-reading this comment I take this back since even if we getrollup-plugin-node-resolve
to skip resolution we might not want to treat the dependency as totally external but rather want Rollup to resolve it some other way.The text was updated successfully, but these errors were encountered: