Tools: Bundler is not building properly under Windows

Created on 22 Jan 2017  路  9Comments  路  Source: Polymer/tools

Description

On Windows the components that should have dependencies are broken, but everything works fine under Linux.

Versions & Environment

  • polymer-build: 0.6.0
  • node: 6.9.1
  • Operating System: Windows 10

Steps to Reproduce

Steps to reproduce are available on PolymerElements/generator-polymer-init-custom-build#54.

Expected Results

Expect the src/my-app.html in build to have all dependencies inlined.

Actual Results

Currently src/my-app.html have all dependencies changed to empty lines.

Simple fix

It works, but not providing PR as not sure if it is the right direction to solve it properly.

The bug seems related to changes in https://github.com/Polymer/polymer-build/commit/221e0e0eac4e10a059a7df11d4d48d605df17c3c

In analyzer.ts file change below lines:

    if (url.startsWith(this.config.root)) {
      url = urlFromPath(this.config.root, url);
    }

to

        let urlPath = process.platform === 'win32' ? url.replace(/\//g, '\\') : url;
        if (urlPath.startsWith(this.config.root)) {
            url = urlFromPath(this.config.root, urlPath);
        }

Also it looks there is an issue on windows with changling drive letters, as for some files accept() gets uppercased drive letter and for some lowercased, so I had to add below to do below in polymer-project-config as a temporary solution:

            if (process.platform === 'win32') {
                this.root = this.root.substr(0, 1).toLowerCase() + this.root.substr(1);    
            }
build

Most helpful comment

@NeoLegends We're working on it today

All 9 comments

In analyzer.ts file change below lines:
to

Wouldn't path.normalize be the better solution?

Thanks, you are right. The line:

let urlPath = process.platform === 'win32' ? url.replace(/\//g, '\\') : url;

can be replaced with just:

let urlPath = path.normalize(url);

But normalize() can sometimes do a bit more (replace .. etc.). I was not sure if it will be OK, but it may be :)

@gluwer thanks for digging in and finding the issue! This code is being removed in https://github.com/Polymer/polymer-build/pull/108 and will be fixed once that is merged.

@FredKSchott Any idea when #108 will be merged?

@NeoLegends We're working on it today

Great!

Update on this? I see you all got #108 merged in. Thanks for the great work on this!

@stramel 0.8.1 bundles correctly on my machine. Install the new version and you should be good.

Confirm that 0.8.1 solved the problem.

Was this page helpful?
0 / 5 - 0 ratings