Summary
Currently, WCC uses Acorn to parse every component, even when it isn't necessary. Regex can be used to locate imports and customElements definitions for .js files with more efficiency. Removing Acorn from wcc.js so it is only a dependency of the JSX loader means that eventually modularizing the JSX loader becomes a simpler task. Separating these concerns seems worthwhile.
Proposal:
https://github.com/ProjectEvergreen/wcc/tree/enhancement/optimization-reducing-dependencies
Currently passing all tests
Dependencies for wcc.js are reduced to:
import { getParse } from './dom-shim.js';
import { generateParsedJsx } from './jsx-loader.js';
import { serialize } from 'parse5';
import fs from 'fs';
And if the JSX loader is made to be a module in a future PR, the only dependencies for WCC core as a whole would be parse5 and fs.
Optimizations
Numerous other small improvements and a number of added tests.
Summary
Currently, WCC uses Acorn to parse every component, even when it isn't necessary. Regex can be used to locate imports and customElements definitions for .js files with more efficiency. Removing Acorn from wcc.js so it is only a dependency of the JSX loader means that eventually modularizing the JSX loader becomes a simpler task. Separating these concerns seems worthwhile.
Proposal:
https://github.com/ProjectEvergreen/wcc/tree/enhancement/optimization-reducing-dependencies
Currently passing all tests
Dependencies for wcc.js are reduced to:
And if the JSX loader is made to be a module in a future PR, the only dependencies for WCC core as a whole would be parse5 and fs.
Optimizations
Numerous other small improvements and a number of added tests.