[英]Using node.js experimental loaders with rollup
I am using rollup
to bundle my Node.js applications - it allows me to deploy them in production as a single file without relying on npm
.我正在使用
rollup
来捆绑我的 Node.js 应用程序 - 它允许我将它们作为单个文件部署在生产中,而无需依赖npm
。
I also happen to have my own custom loaders for some special format files that I import in my code by calling我也碰巧有我自己的自定义加载器,用于一些特殊格式的文件,我通过调用在我的代码中导入这些文件
node --experimental-loader=./lib/txt-colormap-es-loader.mjs
and then doing node --experimental-loader=./lib/txt-colormap-es-loader.mjs
然后做
import colormap from './colormaps/01.txt';
One of these is handlebars
for which there is a special plugin in rollup.其中之一是在 rollup 中有一个特殊插件的
handlebars
。
But I also have my own custom formats with my own custom loaders.但我也有我自己的自定义格式和我自己的自定义加载器。
Does anyone see any way I could make rollup
work with my custom ES6 loader in Node.js short of writing a new plugin?有没有人看到我可以在 Node.js 中使用我的自定义 ES6 加载器进行
rollup
工作,而不需要编写一个新插件?
I found a suboptimal solution without developing/publishing/maintaining a new rollup
plugin - import the loader itself and call it manually on the file imported as a string.我找到了一个没有开发/发布/维护新
rollup
插件的次优解决方案 - 导入加载器本身并在作为字符串导入的文件上手动调用它。 Importing as a string can be accomplished可以实现作为字符串导入
In development, before bundling, by在开发中,在捆绑之前,由
https://www.npmjs.com/package/import-as-string https://www.npmjs.com/package/import-as-string
In production, with rollup, by在生产中,通过汇总,由
https://www.npmjs.com/package/rollup-plugin-string https://www.npmjs.com/package/rollup-plugin-string
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.