Closed Pat1enceLos closed 2 years ago
Thank you so much for your work. I tried create a vite project and used with your code but I could not see any build error. Could you please show me more clue?
Steps to reproduce:
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. So I tried a new project Vite3 + React18 and use your config file, but still got the error Did you got the error in http://localhost:4173/ ?
I'm really so sorry for that. My mistake, I didn't browse the page.
You can try this:
import parse from 'node-html-parser';
import parse from 'node-html-parser;
It will not work in dev runtime by:
yarn dev
I tried to fix this, but I am not sure this commit will cause trouble with https://github.com/taoqf/node-html-parser/pull/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 hoping for your replay :)
why should we bind attributes to parse function in v5.4.2-0: 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?
Would v5.4.2-0 work for you?
Yes, it works well :)
fix build error when use vite build: