rollup.js 如何在不更改源文件的情况下导入其他文件
rollup.js how to import additional files without changing source files
我的示例基于 rollup.js 基本示例:https://rollupjs.org/guide/en/#rolluprollup
我正在处理的项目需要包含和排除其他文件。 (我知道如何使用 'rollup-plugin-ignore' 插件排除路径。)
如何告诉 rollup.js 在不更改源文件的情况下将文件添加到导入列表(与我在源代码中导入它们相同)。 ?
我试过 commonjs 插件
var commonjs = require('rollup-plugin-commonjs');
var include = ["D:\...abs_path....\components\Auth\FormLogin.jsx"]
commonjs( {"include": include})
但我在输出文件中没有看到 'FormLogin' 组件。
有没有更简单的方法,你能帮帮我吗?
我会感谢你的帮助。
非常感谢你。
这有点不正统,因为 rollup.js 使用 tree-shaking 来分析你的代码,只包含使用过的部分,而你想要包含未使用的部分。
最简单的方法是在命令行中连接,如 windows cmd:
type file_from_rollup.js additional.js > bundle.js
其次,您可以指示汇总使用两个入口点:
rollup main.js libB.js -d ./bundle --format cjs
这将在 ./bundle 文件夹中生成两个捆绑文件,它们都是 tree-shaked
如果在源代码中引用了 FormLogin.jsx(从主入口点看)尝试像
一样禁用 tree shaking
rollup main.js --no-treeshake --file bundle.js --format cjs
看看它是否包括在内。也许 rollup.js 没有正确识别它:https://rollupjs.org/guide/en/#tree-shaking-doesnt-seem-to-be-working
我的示例基于 rollup.js 基本示例:https://rollupjs.org/guide/en/#rolluprollup
我正在处理的项目需要包含和排除其他文件。 (我知道如何使用 'rollup-plugin-ignore' 插件排除路径。)
如何告诉 rollup.js 在不更改源文件的情况下将文件添加到导入列表(与我在源代码中导入它们相同)。 ?
我试过 commonjs 插件
var commonjs = require('rollup-plugin-commonjs');
var include = ["D:\...abs_path....\components\Auth\FormLogin.jsx"]
commonjs( {"include": include})
但我在输出文件中没有看到 'FormLogin' 组件。
有没有更简单的方法,你能帮帮我吗?
我会感谢你的帮助。
非常感谢你。
这有点不正统,因为 rollup.js 使用 tree-shaking 来分析你的代码,只包含使用过的部分,而你想要包含未使用的部分。
最简单的方法是在命令行中连接,如 windows cmd:
type file_from_rollup.js additional.js > bundle.js
其次,您可以指示汇总使用两个入口点:
rollup main.js libB.js -d ./bundle --format cjs
这将在 ./bundle 文件夹中生成两个捆绑文件,它们都是 tree-shaked
如果在源代码中引用了 FormLogin.jsx(从主入口点看)尝试像
一样禁用 tree shakingrollup main.js --no-treeshake --file bundle.js --format cjs
看看它是否包括在内。也许 rollup.js 没有正确识别它:https://rollupjs.org/guide/en/#tree-shaking-doesnt-seem-to-be-working