parse5
parse5 copied to clipboard
Consider exporting `InsertionMode` enum
When creating a custom parser we need to check the insertionMode field against a value. Without the InsertionMode enum exported we have to use a magic number or redefine another enum within our codebase.
Is there any reason preventing us from exporting the enum?
InsertionMode is actually exported: https://github.com/inikulin/parse5/blob/master/packages/parse5/lib/index.ts
We mark it as internal, to avoid clutter in the documentation. But there is nothing stopping you from importing it.
Hey @fb55 I could miss something but InsertionMode was not exported inside parser/index.ts and I couldn't find anywhere that indirectly exports the enum.
I was thinking of tokenizer modes – sorry about the confusion. I'm not sure how useful exporting insertion modes would be, as the parser is pretty hard to extend in the current form (_processToken is only called when re-processing tokens).
The authors of single-spa-layout extended Parser in their project https://github.com/single-spa/single-spa-layout/blob/main/src/server/CustomParser.js.
I'm rewriting that piece of code into TypeScript (after upgrading the parse5 dependency to v7) for a project in my company and that's when I encountered InsertionMode enum.
I think we could export the enum inside its file but not in the package index. The enum itself was marked as internal so that people use it at their own risk.