Javascript Svelte汇总[导出名称]不是由节点\u模块导出的/

Javascript Svelte汇总[导出名称]不是由节点\u模块导出的/,javascript,node.js,svelte,rollup,Javascript,Node.js,Svelte,Rollup,我正试图从以下位置导入模块:import{hyphenateHTMLSync}来自“hyphen/fr”在Svelte模块的脚本标记中,但我得到错误:“hyphenateHTMLSync”不是由rollup中的node_modules/hyphen/fr/index.js导出的 quesiton中的模块文件如下所示: 节点模块/hyphen/fr/index.js module.exports = require("../export-contract.js")( require("..

我正试图从以下位置导入模块:
import{hyphenateHTMLSync}来自“hyphen/fr”在Svelte模块的脚本标记中,但我得到
错误:“hyphenateHTMLSync”不是由rollup中的node_modules/hyphen/fr/index.js导出的

quesiton中的模块文件如下所示:

节点模块/hyphen/fr/index.js

module.exports = require("../export-contract.js")(
    require("../patterns/fr.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
  };
};
node_modules/hyphen/export contract.js

module.exports = require("../export-contract.js")(
    require("../patterns/fr.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
  };
};
js包含创建断字器的函数


我对Rollup、Svelte甚至Node都不太了解,不知道如何解决这个问题。

Rollup需要额外的插件(
@Rollup/plugin Node resolve
@Rollup/plugin commonjs
)来处理commonjs模块,如前所述

给出了一个使用这两个插件的非常基本的汇总示例配置


在您的特定用例中,如果您在使用基本配置时仍然存在问题,您可能需要深入研究commonjs插件的选项。

如前所述,Rollup需要额外的插件(
@Rollup/plugin node resolve
@Rollup/plugin commonjs
)来处理commonjs模块

给出了一个使用这两个插件的非常基本的汇总示例配置


在您的特定用例中,如果您在使用基本配置时仍然存在问题,您可能需要深入研究commonjs插件的选项。

这两个插件都已经在我的汇总配置文件中。我使用了预先配置好的wich。我尝试为CommonJS使用DynamicRequestAgets参数,添加了插件的两个核心组件,但仍然遇到了同样的问题。不确定我是否在DynamicRequest上做错了什么
commonjs({dynamicRequireTargets:['node_modules/hyphen/index.js','node_modules/hyphen/hyphen.js']})
为了省心,我将添加动态导入中涉及的所有模块,即
commonjs({dynamicRequireTargets:['node_modules/hyphen/export contract.js','node_modules/hyphen/hyphen.js','node_modules/hyphen/patterns/fr.js']}
。如果这不起作用,那么您可能必须找到另一种解决方法,即从
模式/fr.js
导入,
hyphen.js
并手动调用
createHyphenator
(您可以在一个单独的JS文件中完成所有这些工作,导出函数调用的结果,并在项目中需要的任何地方导入这些结果)。我最后做了最后一部分,导入
createHyphenator
和模式并导出。感谢您的帮助!这两个插件都已经在我的汇总配置文件中。我使用了预先配置好它们的wich。我尝试为CommonJS使用DynamicRequestAgets参数,添加了插件的两个核心组件和I sti我也遇到了同样的问题。不确定我是否对DynamicRequestGets做了什么错误。
commonjs({dynamicRequestGets:['node\u modules/hyphen/index.js','node\u modules/hyphen/hyphen.js']})
为了省心,我会添加动态导入中涉及的所有模块,即
commonjs({dynamicRequestGets:['node_modules/hyphen/export contract.js','node_modules/hyphen/hyphen.js','node_modules/hyphen/patterns/fr.js']}
。如果这不起作用,那么您可能必须找到另一种解决方法,即从
模式/fr.js
导入,
hyphen.js
并手动调用
createHyphenator
(您可以在一个单独的JS文件中完成所有这些工作,导出函数调用的结果,并在项目中的任何需要的地方导入这些结果)。我最后完成了最后一部分,导入了
createHyphenator
和模式并进行了导出。感谢您的帮助!