Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Rollupjs+;bable dynamic不需要捆绑文件_Javascript_Babeljs_Rollupjs - Fatal编程技术网

Javascript Rollupjs+;bable dynamic不需要捆绑文件

Javascript Rollupjs+;bable dynamic不需要捆绑文件,javascript,babeljs,rollupjs,Javascript,Babeljs,Rollupjs,我最近进入了react and rollup,我有一个动态要求,但是,当我执行rollup-c将其构建到特定文件夹(在我的例子中是“dist”)时,动态加载的文件不会被编译或复制。这意味着,如果我在应用程序中使用文件,它将抛出一个错误,因为它将无法在该位置找到该文件 所需的参数是:const{data,validIDs}=require(“../../data/”+nextProps.path+“/”+nextProps.filename+”.js”) 我看到有一些插件允许动态导入,但这些文件导

我最近进入了react and rollup,我有一个动态要求,但是,当我执行
rollup-c
将其构建到特定文件夹(在我的例子中是“dist”)时,动态加载的文件不会被编译或复制。这意味着,如果我在应用程序中使用文件,它将抛出一个错误,因为它将无法在该位置找到该文件

所需的参数是:
const{data,validIDs}=require(“../../data/”+nextProps.path+“/”+nextProps.filename+”.js”)

我看到有一些插件允许动态导入,但这些文件导出的变量如下
module.exports.data={}
,我无法让它使用导入

汇总设置:

export default {
input: pkg.source,
output: [
    { dir: pkg.buildDir+ "cjs", format: 'cjs' },
    { dir: pkg.buildDir+ "esm", format: 'esm' },
],
plugins: [
    peerDepsExternal(),
    external(),
    babel({
        exclude: 'node_modules/**',
        plugins: ['@babel/transform-runtime'],
        babelHelpers: 'runtime'
    }),
    resolve(),
    styles({
        postcss: {
            plugins: [
                autoprefixer()
            ]
        },
        minimize: true
    }),
    //terser()
],
external: Object.keys(pkg.peerDependencies || {}),
};
谢谢