transpiler: normalize Dart library name
`file2module` was used for normalizing paths where `-` is fine. This normalizes non-word characters only when generating the Dart library name.
This commit is contained in:
parent
cfc5fdc60d
commit
6efb7f9017
|
@ -1,8 +1,5 @@
|
||||||
function file2moduleName(filePath) {
|
function file2moduleName(filePath) {
|
||||||
return filePath
|
return filePath
|
||||||
// module name should not include non word characters (e.g. '-')
|
|
||||||
// -> important for Dart
|
|
||||||
.replace(/[^\w.\/]/g, '_')
|
|
||||||
// module name should be relative to `modules` and `tools` folder
|
// module name should be relative to `modules` and `tools` folder
|
||||||
.replace(/.*\/modules\//, '')
|
.replace(/.*\/modules\//, '')
|
||||||
.replace(/.*\/tools\//, '')
|
.replace(/.*\/tools\//, '')
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {ParseTreeWriter as JavaScriptParseTreeWriter, ObjectLiteralExpression} f
|
||||||
export class DartParseTreeWriter extends JavaScriptParseTreeWriter {
|
export class DartParseTreeWriter extends JavaScriptParseTreeWriter {
|
||||||
constructor(moduleName, outputPath) {
|
constructor(moduleName, outputPath) {
|
||||||
super(outputPath);
|
super(outputPath);
|
||||||
this.libName = moduleName.replace(/\//g, '.');
|
this.libName = moduleName.replace(/\//g, '.').replace(/[^\w.\/]/g, '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
// VARIABLES - types
|
// VARIABLES - types
|
||||||
|
|
Loading…
Reference in New Issue