[英]In Rollup How do I get --external to work on the command line directly pointing to the module to exclude? (no node resolve plugin)
The documents talk about using external
in the context of the node resolve plugin, but I am not using that.文档讨论在节点解析插件的上下文中使用external
,但我没有使用它。 I would like to exclude lit-html (which is native es6 modules) so that those imports remain in the bundle.我想排除 lit-html(这是原生 es6 模块),以便这些导入保留在包中。
In my module I import them with import { html, render } from '../../node_modules/lit-html/lit-html.js'
;在我的模块中,我使用 import { html, render } from '../../node_modules/lit-html/lit-html.js'
导入它们; and it works great in the browser.它在浏览器中运行良好。
I have tried every permutation of path including relative path like rollup --format=esm --file=dist/bundle.js -- src/main.js --external 'node_modules/lit-html/lit-html.js'
and just get [!] Error: Could not resolve entry (--external)
.我已经尝试了所有路径排列,包括相对路径,如rollup --format=esm --file=dist/bundle.js -- src/main.js --external 'node_modules/lit-html/lit-html.js'
和只是得到[!] Error: Could not resolve entry (--external)
。
It does not even say if the file is found, never mind what the problem is.它甚至不说是否找到了文件,不管问题是什么。
Seems your command is wrong, use -i
to indicate the input file or try moving -- src/main.js
to the end of the command without the dashes.似乎您的命令有误,请使用-i
指示输入文件或尝试将-- src/main.js
移动到命令末尾而不带破折号。
Regarding the external part, don't think it will work without using the exact id of the import but worth a try.关于外部部分,不要认为它会在不使用导入的确切 id 的情况下工作,但值得一试。
Using a config file:使用配置文件:
module.exports = {
input: 'src/main.js',
external:[
'../../node_modules/lit-html/lit-html.js'
],
output: {
format: 'esm',
file: './dist/bundle.js',
sourcemap: true
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.