简体   繁体   中英

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 .

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

import colormap from './colormaps/01.txt';

One of these is handlebars for which there is a special plugin in rollup.

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?

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. Importing as a string can be accomplished

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM