rafaelmussi / angular-templatecache-webpack-plugin

Webpack plugin that concatenates and registers AngularJS templates in the $templateCache.
MIT License
4 stars 16 forks source link

Setting for selecting a type of path separator #1

Open ghost opened 3 years ago

ghost commented 3 years ago

We are encountering the following error on our development workstations running Windows:

TS1125: Hexadecimal digit expected

Looking at our source code, we realized that the error was thrown on this line of the file we've specified in outputFilename:

$templateCache.put('formly\template\ui-select.html', …

What happens here is that the \ui-select is being interpreted as a Unicode character marker, due to \u.

In our case, the JavaScript/TypeScript code will always use the / path separator (e.g. formly/template/ui-select.html) when accessing the template from code, regardless of the execution environment. As a consequence, even if \u were not causing issues, the template cache would always fail to retrieve the appropriate value.

We've traced the root cause to this line:

  let filename = path.relative(htmlRootDir, file);

where module "path" provides relative URLs using the system separator.

We haven't found an option that would allow us to specify that path fragments (e.g. formly\template\ui-select.html) in the file generated by angular-templatecache-webpack-plugin should use the Unix separator (/) instead of the Windows one (\). This issue is for requesting that such an option be added.

I'm even wondering if the path separator could not just be "forced" to the Unix one.