Comments (7)
I've run into this as well, but the problem isn't that the loader doesn't try to handle it -- it's that it's not doing it correctly. Two specific problems:
- On line 11 where it reads:
relativeTo.replace('/', path.sep);
this is only going to replace the first / with a \ on Windows. .replace() also returns a new string instead of updating the input. It needs to read:
relativeTo = relativeTo.replace(/\//g, path.sep);
- Since the file name is treated as a regular expression, converting / to \ won't work. In addition, other characters like a . in a path need to be escaped because . is a letter match. Because of this, paths should never be passed directly into .match() in JS. Instead, use a function like this:
function escapeRegExp(string) {
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
and then call .match() like so:
var relativeToMatch = this.resource.match(new RegExp("^" + escapeRegExp(relativeTo), "g"));
This will (unfortunately?) prevent using regular expressions, but ngtemplate-loader is already going to break on any system (not just Windows) if there's a ., [, etc. in the path so this feature may need to be rethought....
from ngtemplate-loader.
Will there be a fix for this soon?
from ngtemplate-loader.
Hi @epelc, I will take a look tonight.
from ngtemplate-loader.
@WearyMonkey Thanks this looks like it will fix my directives loading issue
from ngtemplate-loader.
I'm confused here. I have everything set up with *nix style path separators and it works great. When I try to build on windows it barfs. I see this, but the way I'm reading the above comments, the build tool (aka, this library) should be properly handling my *nix style paths but I don't think it is.
Can someone please explain what this fix is supposed to do? Is it supposed to make the build platform agnostic?
from ngtemplate-loader.
@WearyMonkey in version 2.0.0, while build on Windows, template path separators become "\\". In version 1.3.1 everything was working fine.
from ngtemplate-loader.
Fixed in version 2.0.1, thank you!
from ngtemplate-loader.
Related Issues (20)
- DeprecationWarning: loaderUtils HOT 2
- Generated file path is causing problems on Windows HOT 1
- Cannot use ES6 modules and TypeScript HOT 3
- Parameter Interpolation HOT 1
- changelog
- sensible defaults
- Webpack v3 loaderUtils.parseQuery() deprecation warning HOT 2
- ERROR in Error: Child compilation failed: Module build failed: Error: The path for file doesn't contain relativeTo param HOT 6
- Error ReferenceError: window is not defined HOT 2
- ng-include relativeTo prefix slash HOT 6
- Breaks while requiring html files that start with comments HOT 1
- relativeTo parameter is not working HOT 1
- Directive templateurl is not working with lazyloading module in ui-router. HOT 2
- Loader injects strange text in generated html file. ERROR "window is not defined " if html-loader is after ngtemplate-loader in config HOT 1
- not working with babel-7 HOT 1
- ngtemplate-loader generated code `path` variable refers to the absolute path. HOT 1
- Use ngtemplate-loader with JEST transform HOT 1
- Stopped working with html-loader v1.0.0 HOT 5
- Uncaught Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead HOT 2
- Module build failed Error: The path for file doesn't contain relativeTo param - Not able to bundle the htmls of parallel module HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngtemplate-loader.