Will webpack accept AST as an input module?

Webpack is currently dealing with files that it analyzes through bootloaders to determine dependencies.

When using babel, babel parses the file and has enough information to directly tell the web folder what dependencies it has. As far as I know, there is no way to transfer this rich information directly to webpack, babel should generate a JavaScript file as text, which then repackages to extract the dependency information.

(a) Is my resume correct? Is this what is happening now? (b) Are there any plans for closer integration between layers? I expect this to have a pretty decent impact on build time.

+4
source share
1 answer

(a) Yes, this summary is correct. This is mainly because different instruments did not have a common AST format. This has recently changed with the ESTree Spec . However, I do not know how compatible these ASTs are in real projects. Comparing AST to astexplorer.net , it seems that AST is somewhat similar. Webpack's modern design is wasteful, but provides good compatibility.

() . . JS , : webpack Sass CSS, CSS postcss-, CSS, CSS css-loader ( PostCSS) JS, webpack, . ( ), , .

, . Babel PostCSS. , autoprefixer-loader PostCSS. API-, , CSS-TAG Houdini Task Force JavaScript.

, Babel PostCSS. , , , webpack , , webpack. , AST .

webpack:

, value/inputValue. . , , . webpack @1. - webpack @2 ( ).
- sokra , webpack @2,

. JavaScript return, this.callback. , . - ( ). , . , , . .


Btw: . .

+6

All Articles