NightlyCommit / twing-loader

*** This project is now hosted in GitLab ***
https://gitlab.com/nightlycommit/twing-loader
12 stars 13 forks source link

Windows compatibility #14

Closed DerekRoth closed 5 years ago

DerekRoth commented 5 years ago

On Windows, the loader fails to generate a valid code and triggers syntax errors:

SyntaxError: Bad character escape sequence (1:65)
  Module parse failed: Bad character escape sequence (1:65)
  File was processed with these loaders:
   * ./node_modules/html-webpack-plugin/lib/loader.js
   * ./node_modules/twing-loader/dist/index.js
  You may need an additional loader to handle the result of these loaders.
  > const {cache, loader, getEnvironment} = require('E:\bamboo-home\xml-data\build-dir\FRONT-JOB1\sites\node_modules\twing-loader\dist\runtime.js');
  | const env = getEnvironment(require('E:\bamboo-home\xml-data\build-dir\FRONT-JOB1\sites\environment.js'));
  | cache.write('__HASHED__3f3518231f054cf969de2034816d600e1a9b4c3268efab00906999bd1f8d8b20', (() => {let module = {:

I think this is because in the loader, require.resolve is used to get the path of some files, but this path will contain backslashes on Windows that should be escaped.

ericmorand commented 5 years ago

Yes, most probably. We had the issue at some point with the filesystem loader too.

ericmorand commented 5 years ago

@DerekRoth can you give 2.0.2 a try?

DerekRoth commented 5 years ago

Just tested it, it is still failing when trying to require a template here:

for (let foundTemplateName of nodeVisitor.foundTemplateNames) {
            parts.push(`require('${foundTemplateName}');
}
ericmorand commented 5 years ago

Good point. I also need to run the integration test suite with both separators. Will fix that.

ericmorand commented 5 years ago

Will be covered by #17.