Skip to content

win32 incorrect assigned module names when filenames created via path.join / resolve #426

Open

Description

@DimitarChristoff

Using r.js for a custom builder of components on osx and win32 machines. for various reasons, path management in the builder is done via path.join / resolve / relative etc, which is taking into account path.sep (/ or ).

Example passed to config for r.js:

this.basePath = '../src;
this.componentPath = 'components';
var componentId = 'widget';
config.include = [ path.join(this.basePath, this.componentPath, componentId, 'main') ];

on osx this results in ../src/components/widget/main' and the resulting module gets a normalizedname` of (relative to the correct baseUrl):

define("components/widget/main", [deps], function(){});

on windows, we get the ..\\src\\components\\widget\\main passed to r.js and the module name becomes:

define("components\widget\main", [deps], function(){});

... which simply does not match any require statements in the code after. since it's for web building (URI), shouldn't there be a way to normalize the names for that?

Activity

  1. robertgorecki commented on Apr 9, 2013

    @robertgorecki

    I would also vote for that. We work in multiple environments (osx, windows) and such path normalization during r.js build would be nice.

  2. jrburke commented on Apr 9, 2013

    @jrburke
    Member

    The main, include, exclude, excludeShallow, and insertRequire options expect module IDs, which should all be front slashed strings, not back-slashed ones. In this case, using path.join is not necessary.

    I need to do a better job though of enforcing that, as I can see where it is not obvious. Putting this in the 2.2.0 bucket.

  3. DimitarChristoff commented on Apr 10, 2013

    @DimitarChristoff
    Author

    yes, path.join is not needed here but this is written to illustrate a point. the context is a cli builder that works with files to find what and how to build and it passes the end result to require optimizer. I am currently working around this by replacing \ with / beforehand anyway, just thought it was never going to be useful to leave \ in the module names.

  4. modified the milestones: 2.2.0, 3.0 on Mar 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions