gpt4 book ai didi

javascript - 如何将 alasql 与 webpack 结合使用?

转载 作者:行者123 更新时间:2023-11-27 22:49:00 25 4
gpt4 key购买 nike

我无法将 alasql 与 webpack 一起使用。

我安装了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.

有什么想法如何将 alasql 包含在 webpack 中吗?

最佳答案

结账 https://github.com/agershun/alasql/issues/440有关详细信息,但他们似乎已经更新了忽略插件的正则表达式,并且您需要确保使用 json-loader 模块来解析 alasql 源中的任何 json 文件。

TLDR;(webpack 配置)

...
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']
},
...
]

关于javascript - 如何将 alasql 与 webpack 结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38204051/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com