"You may need an additional loader to handle the result of these loaders." "您可能需要一个额外的加载器来处理这些加载器的结果。"

11 浏览
0 Comments

"You may need an additional loader to handle the result of these loaders." "您可能需要一个额外的加载器来处理这些加载器的结果。"

我目前正在尝试为ReactJs构建一个状态管理库。但是,一旦我将其实现到我的React项目中(使用create-react-app创建),就会出现以下错误:

编译失败。

path/to/agile/dist/runtime.js 116:104

模块解析失败:意外的标记(116:104)

文件已使用以下加载器进行处理:

* ./node_modules/babel-loader/lib/index.js

您可能需要另一个加载器来处理这些加载器的结果。

| if (subscriptionContainer instanceof sub_1.CallbackContainer) subscriptionContainer.callback(); // If Component based subscription call the updateMethod which every framework has to define

|

> if (subscriptionContainer instanceof sub_1.ComponentContainer) if (this.agileInstance.integration?.updateMethod) this.agileInstance.integration?.updateMethod(subscriptionContainer.component, Runtime.formatChangedPropKeys(subscriptionContainer));

| }); // Log Job

|

如果我注释掉错误中提到的代码行,它会跳到另一个地方并抱怨。但这不可能是语法错误,因为TypeScript在IDE中也会抱怨。

工具的工作原理:

首先,您必须定义一个框架,这里是React。然后,您可以创建一个State,并通过Hook将此State订阅到React Functional Component。

用于将State绑定到React组件的Hook只是创建一个回调,触发重新渲染(通过改变useReducer),并将此回调分配给订阅的State。

如果您想了解更多信息,请查看此存储库:

https://github.com/agile-ts/agile

依赖项:

第三方状态管理库:

"dependencies": {

"@types/chai": "^4.2.12",

"@types/mocha": "^8.0.2",

"chai": "^4.2.0",

"eslint-config-prettier": "^6.11.0",

"mocha": "^8.1.1",

"prettier": "2.0.5",

"ts-node": "^8.10.2",

"tsc-watch": "^4.1.0",

"tslib": "^2.0.0",

"typescript": "^3.9.7"

}

  • Node版本:v14.8.0

React项目:

"dependencies": {

"@testing-library/jest-dom": "^4.2.4",

"@testing-library/react": "^9.3.2",

"@testing-library/user-event": "^7.1.2",

"@types/jest": "^24.0.0",

"@types/node": "^12.0.0",

"@types/react": "^16.9.0",

"@types/react-dom": "^16.9.0",

"react": "^16.13.1",

"react-dom": "^16.13.1",

"react-scripts": "3.4.3",

"typescript": "~3.7.2",

"agile-framework": "file:../../"

},

  • React版本:16.13.1
  • NPM版本:6.14.7
0