我的图书馆里有babel loader。仍然在将纱线服务时将库添加到react应用程序后,仍然出现上述错误。
这是库中的webpack.dev.config.js(在webpack.config.js中必需)-
//webpack.dev.config.js
const babelRCPath = require('@appfabric/infra-scripts').getconfigPath('babel','plugin');
const babelRCGenerator = require(babelRCPath);
const babelRC = babelRCGenerator([]);
module.exports = {
{
BaseModule: `${process.cwd()}/src/BaseModule`,BaseObject: `${process.cwd()}/src/BaseObject`,BaseWidget: `${process.cwd()}/src/widgets/BaseWidget`,HOCWidget: `${process.cwd()}/src/widgets/HOCWidget`,PortalWidget: `${process.cwd()}/src/widgets/PortalWidget`,Baseactivator: `${process.cwd()}/src/application/Baseactivator`,CorePlugin: `${process.cwd()}/src/application/CorePlugin`,BaseAppDelegate: `${process.cwd()}/src/application/appdelegates/BaseAppDelegate`,EmbeddedAppDelegate: `${process.cwd()}/src/default/appdelegates/embedded/EmbeddedAppDelegate`,actionType: `${process.cwd()}/src/application/appdelegates/actions/actionType`,types: `${process.cwd()}/src/application/appdelegates/actions/types`,CommandactionType: `${process.cwd()}/src/application/appdelegates/actions/CommandactionType`,CommandForResponseactionType: `${process.cwd()}/src/application/appdelegates/actions/CommandForResponseactionType`,PluginRegistryService: `${process.cwd()}/src/default/PluginRegistryService`,},mode: 'development',externals: [
'dcl','react','react-dom','prop-types','pubsub','semver','@appfabric/ui-profiler',].map(
// Add this regex to each entry to ensure we don't miss any imports like 'web-shell-core/...`
(value) => new RegExp(`^(${value})((\\\\|/|!).+)?$`),),output: {
path: `${process.cwd()}/build/dist`,filename: '[name].js',library: 'web-shell-core',libraryTarget: 'umd',module: {
rules: [
{
test: /\.(js|jsx)$/,use: {
loader: 'babel-loader',options: babelRC,],};
这是webpack.config.js
const developmentConfig = require('./webpack.dev.config.js');
module.exports = merge(developmentConfig,{
mode: 'production',output: {
filename: '[name].min.js',chunkFilename: '[name].min.js',});
首先,我在库中添加一个新文件Secure.jsx(具有标签)。我在我的申请中做npm install --save <path-to-library>
。完成yarn install
之后。然后,我可以在应用程序的节点模块中看到新文件Secure.jsx。当我尝试运行该应用程序时,出现错误。
请让我知道我缺少什么,以及我必须添加代码的哪一侧(库/应用程序)。