我使用汇总将表单组件的共享库组合在一起,该库使用Formik作为基本层。目前,我收到了下面的“调度程序”编译错误,这是Formik在幕后使用的。
我尝试过手动安装它作为一个单独的npm依赖项,但是仍然会得到以下错误。
[!] Error: 'unstable_runWithPriority' is not exported by node_modules/formik/node_modules/scheduler/index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules/formik/dist/formik.esm.js (9:9)
7: import toPath from 'lodash-es/toPath';
8: import invariant from 'tiny-warning';
9: import { unstable_runWithPriority, LowPriority } from 'scheduler';遵循汇总文档:我尝试使用rollup.config.js的命名导出部分,例如:
plugins: [
peerDepsExternal(),
postcss({ extract: true, plugins: [autoprefixer] }),
json({ include: 'node_modules/**' }),
babel({ exclude: 'node_modules/**', presets: ['@babel/env', '@babel/preset-react'] }),
localResolve(),
resolve({dedupe: [ 'react', 'react-dom' ]}),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/formik/node_modules/scheduler/index.js': ['unstable_runWithPriority'],
'scheduler': ['unstable_runWithPriority'],
'node_modules/scheduler': ['unstable_runWithPriority'],
'./node_modules/scheduler': ['unstable_runWithPriority'],
'../node_modules/formik/node_modules/scheduler/index.js': ['unstable_runWithPriority']
}
}),
globals(),
externals(),
builtins(),
filesize()
]如您所见,我尝试了几个目的地/路径,以获得良好的效果。有谁能为我指出正确的方向,如何重新获得这个编译?或者如何正确定义我的命名导出?我在网络上读到了一些问题,这些问题表明插件数组的顺序可能会影响事物,但我交换了一些,但我仍然感到困惑。
发布于 2019-11-28 11:32:47
你可能认为地球上没有人会犯同样的错误。你就错了。找到了解决办法。(这与插件上的顺序有关)
plugins: [
globals(),
builtins(),
externals(),
babel({ exclude: 'node_modules/**', presets: ['@babel/env', '@babel/preset-react'] }),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/formik/node_modules/scheduler/index.js' : ['unstable_runWithPriority'],
}
}),
peerDepsExternal(),
postcss({ extract: true, plugins: [autoprefixer] }),
json({ include: 'node_modules/**' }),
localResolve(),
resolve({dedupe: [ 'react', 'react-dom' ]}),
filesize()
]发布于 2020-06-04 02:06:44
这个插件命令为我解决了这个问题。
plugins: [
babel({
exclude: 'node_modules/**',
presets: ['@babel/env', '@babel/preset-react'],
}),
typescript({ useTsconfigDeclarationDir: true }),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/formik/node_modules/scheduler/index.js': [
'unstable_runWithPriority',
],
},
}),
peerDepsExternal(),
scss(),
json({
compact: true,
}),
resolve(),
],发布于 2020-09-07 19:46:08
使用以下语法:
namedExports: {
'scheduler': ['unstable_runWithPriority', 'unstable_LowPriority']
}https://stackoverflow.com/questions/59085618
复制相似问题