像这样在我的包中使用绝对路径import { Component1, Component2 } from "common/assets";
并在本地安装并检查后出错
./node_modules/package/dist/package.js 找不到模块:无法解析“/home/max/project/node_modules/package/dist”中的“common/assets”
在组装期间收到警告
(!)未解决的依赖项 common/helpers(由 src/components/Link/index.ts 导入...
我的汇总配置
/* eslint-disable flowtype/require-valid-file-annotation, no-console, import/extensions */
import nodeResolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from "rollup-plugin-babel";
import flow from "rollup-plugin-flow";
import sourceMaps from "rollup-plugin-sourcemaps";
const commonPlugins = [
flow({
pretty: true
}),
sourceMaps(),
nodeResolve({
jsnext: true,
main: true,
browser: true,
extensions: [".ts", ".tsx", ".js", ".jsx"]
}),
babel({
exclude: "node_modules/**"
}),
commonjs({
namedExports: {
react: [
"cloneElement",
"createFactory",
"Component",
"PropTypes",
"createElement",
"createContext"
],
"react-dom": ["render"],
"react-is": ["isElement", "isValidElementType", "ForwardRef"]
}
})
];
const globals = { react: "React", "react-dom": "ReactDOM" };
const configBase = {
input: "./src/index.js",
plugins: commonPlugins
};
const standaloneBaseConfig = {
...configBase,
output: {
file: "dist/package.js",
format: "cjs",
name: "sct",
globals,
sourcemap: true
},
plugins: configBase.plugins
};
export default standaloneBaseConfig;
我可以在我的项目中使用绝对路径吗?如何解决?