Antlr javascript 与 webpack
Antlr javascript with webpack
我正在尝试将 webpack 与 antlr 4 javascript 目标一起使用。我正在关注这份文件。 https://github.com/antlr/antlr4/blob/master/doc/javascript-target.md
如果我理解正确的话,webpack 会将 antlr4 javascript 运行时库中的所有文件和生成的文件(Lexer.js、Listener.js 和 Parser.js)合并为一个文件单个文件。我只需要在我的 html.
中包含这个文件
我不明白文档中要求排除 node.js 模块的这一部分。有人可以解释为什么需要这条线吗?
In the webpack.config
file, exclude node.js only modules using: node: { module: "empty", net: "empty", fs: "empty" }
我也没有任何自定义侦听器或访问器。我可以忽略这些步骤吗?我没有创建任何带有我的解析代码入口点的 index.js 文件。
- write your parse tree handling code by providing your custom listener or visitor, and associated code, using 'require' to load antlr.
- create an index.js file with the entry point to your parsing code (or several if required).**
我在webpack.config.js中理解了为什么我需要这个配置。如果我没有这个配置
node: {
module: "empty",
net:"empty",
fs: "empty"
},
我在 运行 webpack 命令时遇到以下错误:-
./~/antlr4/FileStream.js 中的错误
找不到模块:错误:无法在 /node_modules/antlr4 中解析模块 'fs'
@./~antlr4/FileStream.js38:20-33
违规行是
var fs = isNodeJs ? require("FS") : null;
我正在尝试将 webpack 与 antlr 4 javascript 目标一起使用。我正在关注这份文件。 https://github.com/antlr/antlr4/blob/master/doc/javascript-target.md
如果我理解正确的话,webpack 会将 antlr4 javascript 运行时库中的所有文件和生成的文件(Lexer.js、Listener.js 和 Parser.js)合并为一个文件单个文件。我只需要在我的 html.
中包含这个文件我不明白文档中要求排除 node.js 模块的这一部分。有人可以解释为什么需要这条线吗?
In the
webpack.config
file, exclude node.js only modules using:node: { module: "empty", net: "empty", fs: "empty" }
我也没有任何自定义侦听器或访问器。我可以忽略这些步骤吗?我没有创建任何带有我的解析代码入口点的 index.js 文件。
- write your parse tree handling code by providing your custom listener or visitor, and associated code, using 'require' to load antlr.
- create an index.js file with the entry point to your parsing code (or several if required).**
我在webpack.config.js中理解了为什么我需要这个配置。如果我没有这个配置
node: {
module: "empty",
net:"empty",
fs: "empty"
},
我在 运行 webpack 命令时遇到以下错误:-
./~/antlr4/FileStream.js 中的错误 找不到模块:错误:无法在 /node_modules/antlr4 中解析模块 'fs' @./~antlr4/FileStream.js38:20-33
违规行是
var fs = isNodeJs ? require("FS") : null;