我正试图从以下地方导入一个模块 连字符 像这样。import { hyphenateHTMLSync } from "hyphen/fr";
在一个Svelte模块的脚本标签中,我得到的是: Error: 'hyphenateHTMLSync' is not exported by node_modules/hyphen/fr/index.js
从rollup。
quesiton中的模块文件是这样的。
node_moduleshyphenfrindex.js
module.exports = require("../export-contract.js")(
require("../patterns/fr.js")
);
node_moduleshyphenexport-contract.js。
var createHyphenator = require("./hyphen.js");
module.exports = function (patterns) {
return {
hyphenate: createHyphenator(patterns, { async: true }),
hyphenateHTML: createHyphenator(patterns, { async: true, html: true }),
hyphenateHTMLSync: createHyphenator(patterns, { html: true }),
hyphenateSync: createHyphenator(patterns),
patterns: patterns
};
};
而hyhen.js包含了创建连字符的功能。
我对Rollup、Svelte甚至Node都不够了解,不知道如何解决这个问题。
滚动需要额外的插件(@rollup/plugin-node-resolve
和 @rollup/plugin-commonjs
)来处理CommonJS模块,具体解释如下 此处.
一个非常基本的滚动示例配置使用这两个插件是给出了 此处.
在你的特定使用案例中,如果你在使用基本配置时仍然有问题,你可能会想深入研究一下 动态的RequireTargets commonjs插件的选项。