Repository navigation
fix: fix vite build error - #208
Pat1enceLos wants to merge 1 commit into
Conversation
|
Thank you so much for your work. |
|
I tried in my vite project: import { parse } from 'node-html-parser';
export default function MyComponent() {
useEffect(() => {
const a = parse('<div></div>');
let b = a;
console.log(b);
}, []);
}and it seems works well. tsconfig.json {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@pages/*": ["./pages/*"],
"@static/*": ["./static/*"],
},
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["**/*.ts", "**/*.tsx","src"],
// "include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
|
|
I reproduced in Vite3 + Vue3 before. |
|
I'm really so sorry for that. You can try this: import parse from 'node-html-parser'; |
|
I tried to fix this, but I am not sure this commit will cause trouble with #166 , so I published this in prepatch version. |
|
I thought the reason maybe was: // src/index.ts
export { default as parse, default } from './parse';
// esm/index.js
import nhp from '../dist/index.js' // nhp just stands for parse function
export const CommentNode = nhp.CommentNode;
export const HTMLElement = nhp.HTMLElement;
...and I was a little bit confused, why should we bind attributes to parse function in v5.4.2-0: parse.parse = baseParse;
parse.HTMLElement = HTMLElement;
parse.CommentNode = CommentNode;
parse.valid = valid;
parse.Node = Node;
parse.TextNode = TextNode;
parse.NodeType = NodeType;and also why should there export default parse function |
I think some people would import this lib like this import parse from ''node-html-parser;
// or
import { parse } from ''node-html-parser;I would like both way would work. Would v5.4.2-0 work for you? |
Yes, it works well :) |




fix build error when use vite build: