Giter Site home page Giter Site logo

Comments (7)

warrenrumak avatar warrenrumak commented on August 11, 2024

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:

  1. 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);
  1. 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.

epelc avatar epelc commented on August 11, 2024

Will there be a fix for this soon?

from ngtemplate-loader.

WearyMonkey avatar WearyMonkey commented on August 11, 2024

Hi @epelc, I will take a look tonight.

from ngtemplate-loader.

epelc avatar epelc commented on August 11, 2024

@WearyMonkey Thanks this looks like it will fix my directives loading issue

from ngtemplate-loader.

icfantv avatar icfantv commented on August 11, 2024

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.

victordidenko avatar victordidenko commented on August 11, 2024

@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.

victordidenko avatar victordidenko commented on August 11, 2024

Fixed in version 2.0.1, thank you!

from ngtemplate-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.