我没有在webpack中使用alasql。
我安装了alasql
npm install --save alasql
正如npmjs page所述,我将此添加到我的webpack.config.js
:
plugins: [
new webpack.IgnorePlugin(/(^fs$|xlsx|xls|^path$)/),
然后在我的代码中我做
import alasql from 'alasql';
这会导致webpack失败并显示以下错误消息:
WARNING in ./~/alasql/dist/alasql.js
Critical dependencies:
3197:70-77 require function is used in a way in which dependencies cannot be statically extracted
17317:155-162 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/alasql/dist/alasql.js 3197:70-77 17317:155-162
WARNING in ./~/alasql/dist/alasql.js
Module not found: Error: Cannot resolve module 'vertx' in C:\Users\epl\developement\woodstore\node_modules\alasql\dist
@ ./~/alasql/dist/alasql.js 4456:667-677
WARNING in ./~/alasql/dist/alasql-worker.js
Critical dependencies:
70:155-162 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/alasql/dist/alasql-worker.js 70:155-162
WARNING in ./~/alasql/dist/alasql-worker.min.js
Critical dependencies:
2:383-390 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/alasql/dist/alasql-worker.min.js 2:383-390
WARNING in ./~/alasql/dist/alasql.d.ts
Module parse failed: C:\Users\epl\developement\woodstore\node_modules\alasql\dist\alasql.d.ts The keyword 'interface' is reserved (7:0)
You may need an appropriate loader to handle this file type.
SyntaxError: The keyword 'interface' is reserved (7:0)
at Parser.pp.raise (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:923:13)
at Parser.pp.parseIdent (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:674:203)
at Parser.pp.parseExprAtom (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:286:21)
at Parser.pp.parseExprSubscripts (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:228:19)
at Parser.pp.parseMaybeUnary (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:207:17)
at Parser.pp.parseExprOps (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:154:19)
at Parser.pp.parseMaybeConditional (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:136:19)
at Parser.pp.parseMaybeAssign (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:112:19)
at Parser.pp.parseExpression (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:88:19)
at Parser.pp.parseStatement (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:1771:23)
at Parser.pp.parseTopLevel (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:1666:21)
at Parser.parse (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:1632:17)
at Object.parse (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\acorn\dist\acorn.js:885:44)
at Parser.parse (C:\Users\epl\developement\woodstore\node_modules\webpack\lib\Parser.js:902:15)
at DependenciesBlock.<anonymous> (C:\Users\epl\developement\woodstore\node_modules\webpack\lib\NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (C:\Users\epl\developement\woodstore\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
@ ./~/alasql/dist ^\.\/.*$
WARNING in ./~/alasql/dist/alasql.min.js
Critical dependencies:
9:17799-17806 require function is used in a way in which dependencies cannot be statically extracted
14:24021-24028 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/alasql/dist/alasql.min.js 9:17799-17806 14:24021-24028
ERROR in ./~/alasql/~/request/~/forever-agent/index.js
Module not found: Error: Cannot resolve module 'net' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\forever-agent
@ ./~/alasql/~/request/~/forever-agent/index.js 6:10-24
ERROR in ./~/alasql/~/request/~/forever-agent/index.js
Module not found: Error: Cannot resolve module 'tls' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\forever-agent
@ ./~/alasql/~/request/~/forever-agent/index.js 7:10-24
ERROR in ./~/alasql/~/request/~/tough-cookie/lib/cookie.js
Module not found: Error: Cannot resolve module 'net' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\tough-cookie\lib
@ ./~/alasql/~/request/~/tough-cookie/lib/cookie.js 32:10-24
ERROR in ./~/alasql/~/request/~/tough-cookie/lib/cookie.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\tough-cookie\lib
@ ./~/alasql/~/request/~/tough-cookie/lib/cookie.js 38:14-40
ERROR in ./~/alasql/~/request/~/tunnel-agent/index.js
Module not found: Error: Cannot resolve module 'net' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\tunnel-agent
@ ./~/alasql/~/request/~/tunnel-agent/index.js 3:10-24
ERROR in ./~/alasql/~/request/~/tunnel-agent/index.js
Module not found: Error: Cannot resolve module 'tls' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\tunnel-agent
@ ./~/alasql/~/request/~/tunnel-agent/index.js 4:10-24
ERROR in ./~/alasql/~/request/~/mime-types/~/mime-db/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\mime-types\node_modules\mime-db
@ ./~/alasql/~/request/~/mime-types/~/mime-db/index.js 11:17-37
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 4:9-32
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 5:14-42
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 6:11-36
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 7:10-34
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 8:11-36
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 9:9-32
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 10:7-28
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 11:7-28
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 12:8-30
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 13:15-44
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 14:12-38
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 15:10-34
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 16:11-36
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 17:12-38
ERROR in ./~/alasql/~/request/~/har-validator/lib/schemas/index.js
Module not found: Error: Cannot resolve module 'json-loader' in C:\Users\epl\developement\woodstore\node_modules\alasql\node_modules\request\node_modules\har-validator\lib\schemas
@ ./~/alasql/~/request/~/har-validator/lib/schemas/index.js 18:11-36
webpack: bundle is now VALID.
有关如何在webpack中包含alasql的任何想法吗?
答案 0 :(得分:0)
Checkout https://github.com/agershun/alasql/issues/440了解详细信息,但他们似乎更新了ignore插件的正则表达式,您需要确保使用json-loader模块来解析alasql源中的任何json文件。
TLDR; (webpack config)
...
plugins: [
...
new IgnorePlugin(/(^fs$|cptable|jszip|xlsx|xls|^es6-promise$|^net$|^tls$|^forever-agent$|^tough-cookie$|cpexcel|^path$)/),
...
],
...
loaders: [
...
{
test: /\.json$/,
loader: 'json',
include: [__dirname, '/node_modules']
},
...
]