Skip to content

Commit 19ee553

Browse files
TomVistazhao lei tao
and
zhao lei tao
authored
feat: 添加了类构造支持 (#3)
Co-authored-by: zhao lei tao <[email protected]>
1 parent 8046cf6 commit 19ee553

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function loader(
2121
const fullPath = webpackRemainingChain[webpackRemainingChain.length - 1];
2222
const filename = path.relative(process.cwd(), fullPath);
2323

24-
const file = parse(source, { sourceType: 'module', plugins: ['jsx', 'typescript'] });
24+
const file = parse(source, { sourceType: 'module', plugins: ['jsx', 'typescript', 'decorators-legacy'] });
2525

2626
if (!(filename.endsWith('.jsx') || filename.endsWith('.tsx'))) {
2727
return source;
@@ -44,6 +44,12 @@ export default function loader(
4444
local: name,
4545
id: hash(`${filename}-${name}`),
4646
})));
47+
} else if (t.isClassDeclaration(declaration)) {
48+
const name = declaration.id.name
49+
hotComponents.push({
50+
local: name,
51+
id: hash(`${filename}-${name}`),
52+
})
4753
} else if (specifiers.length) {
4854
for (const spec of specifiers) {
4955
if (t.isExportSpecifier(spec) && t.isIdentifier(spec.exported)) {

0 commit comments

Comments
 (0)