Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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
Typescript 通过网页包意外加载令牌_Typescript_Webpack_Quill - Fatal编程技术网

Typescript 通过网页包意外加载令牌

Typescript 通过网页包意外加载令牌,typescript,webpack,quill,Typescript,Webpack,Quill,我试图通过NodeJS应用程序中的Webpack加载,但遇到以下错误: ERROR in ./node_modules/parchment/src/blot/scroll.ts 17:18 Module parse failed: Unexpected token (17:18) You may need an appropriate loader to handle this file type. | | class ScrollBlot extends ContainerBlot { >

我试图通过NodeJS应用程序中的Webpack加载,但遇到以下错误:

ERROR in ./node_modules/parchment/src/blot/scroll.ts 17:18
Module parse failed: Unexpected token (17:18)
You may need an appropriate loader to handle this file type.
|
| class ScrollBlot extends ContainerBlot {
>   static blotName = 'scroll';
|   static defaultChild = 'block';
|   static scope = Registry.Scope.BLOCK_BLOT;
 @ ./node_modules/parchment/src/parchment.ts 6:0-39 32:10-20
 @ ./node_modules/quill/core.js
 @ ./src/modules/Quill/quill.ts
 @ ./src/routes/Node/Demo/index.tsx
 @ ./src/routes/Node/index.tsx
 @ ./src/routes/index.tsx
 @ ./src/App.tsx
 @ ./src/index.tsx
这是可能的,因为羽毛笔提供了一个新的,但我不能让它的工作

我的网页包配置文件的缩写版本:

module.exports={
...
决心:{
别名:{
“羊皮纸”:path.resolve(_dirname,../node_modules/parchamet/src/parchamet.ts'),
'quill$':path.resolve(uu dirname,'../node_modules/quill/quill.js'),
},
扩展:['.js'、'.jsx'、'.json'、'.ts'、'.tsx'],
},
规则:[
{
强制执行:“预”,
测试:/\.js$/,,
加载器:“源地图加载器”,
排除:/node_模块/,
},
{
测试:/\.ts(x?$/,,
使用:[{
加载器:“ts加载器”,
选项:{
编译器选项:{
声明:虚假,
目标:‘es5’,
模块:“commonjs”
},
transpileOnly:正确
},
}],
},
...
};
和一个缩写的package.json:

"dependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.5",
    "babel-preset-es2015": "^6.24.1",
    "parchment": "^1.1.4",
    "quill": "^1.3.6",
    "ts-loader": "^4.5.0"
  },
  "devDependencies": {
    "@svgr/webpack": "^4.2.0",
    "@types/quill": "^2.0.2",
    "@types/webpack": "^4.4.19",
    "@types/webpack-env": "^1.13.6",
    "tslint": "^5.11.0",
    "tslint-config-airbnb": "^5.11.1",
    "tslint-config-prettier": "^1.16.0",
    "tslint-react": "^3.6.0",
    "tsutils": "^3.5.1",
    "typescript": "^2.8.3",
    "typings-for-css-modules-loader": "^1.7.0",
    "uglifyjs-webpack-plugin": "^2.0.1",
    "webpack": "^4.26.0",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.14",
    "webpack-merge": "^4.1.4"
  }
}
该错误表明
ts loader
没有编译
scroll.ts
,因为它认为
static
是一个意外标记,但据我所知,加载程序设置正确

你知道我哪里出错了吗?

你知道

'parchment': path.resolve(__dirname, '../node_modules/parchment/src/parchment.ts'),
相反,您应该将其解析为生成的
.js
文件:

'parchment': path.resolve(__dirname, '../node_modules/parchment/dist/parchment.js'),
更多
您的webpack/ts加载器的项目内实例不应编译
node\u模块中的
src
.ts
文件。原因:编译器选项差异/双重编译只是开销。您应该避免这一点,只需进行一次小的编辑:路径是
。/node\u模块/parchamet/dist/parchamet.js
,而不是e> lib
。谢谢。