GeezerVison is showing github.com — fix: componentName can contain dot notation · skymysky/lowcode-engine@3a0ab6d
File tree
Expand file treeCollapse file tree
Open diff view settings
modules/code-generator/src
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: modules/code-generator/src/plugins/common/esmodule.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,7 +16,7 @@ import { |
16 | 16 | IWithDependency, |
17 | 17 | } from '../../types'; |
18 | 18 |
|
19 | | -import { isValidIdentifier } from '../../utils/validate'; |
| 19 | +import { isValidIdentifier, isValidComponentName } from '../../utils/validate'; |
20 | 20 |
|
21 | 21 | // TODO: main 这个信息到底怎么用,是不是外部包不需要使用? |
22 | 22 | const DEP_MAIN_BLOCKLIST = ['lib', 'lib/index', 'es', 'es/index', 'main']; |
@@ -261,7 +261,7 @@ function buildPackageImport( |
261 | 261 | if (!isValidIdentifier(name)) { |
262 | 262 | throw new CodeGeneratorError(`Invalid Identifier [${name}]`); |
263 | 263 | } |
264 | | - if (info.nodeIdentifier && !isValidIdentifier(info.nodeIdentifier)) { |
| 264 | + if (info.nodeIdentifier && !isValidComponentName(info.nodeIdentifier)) { |
265 | 265 | throw new CodeGeneratorError(`Invalid Identifier [${info.nodeIdentifier}]`); |
266 | 266 | } |
267 | 267 | }); |
|
Collapse file
Copy file name to clipboardExpand all lines: modules/code-generator/src/utils/validate.ts +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,10 @@ export const isValidIdentifier = (name: string) => { |
2 | 2 | return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(name); |
3 | 3 | }; |
4 | 4 |
|
| 5 | +export const isValidComponentName = (name: string) => { |
| 6 | + return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF.]*$/.test(name); |
| 7 | +}; |
| 8 | + |
5 | 9 | export const ensureValidClassName = (name: string) => { |
6 | 10 | if (!isValidIdentifier(name)) { |
7 | 11 | return `$${name.replace(/[^_$a-zA-Z0-9]/g, '')}`; |
|