Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

JS compiler emits backslash in require statements on Windows #6823

Closed
lucaswerkmeister opened this issue Dec 11, 2016 · 0 comments
Closed

JS compiler emits backslash in require statements on Windows #6823

lucaswerkmeister opened this issue Dec 11, 2016 · 0 comments

Comments

@lucaswerkmeister
Copy link
Contributor

lucaswerkmeister commented Dec 11, 2016

Reported by @lucono on ceylon-users:

It seems that on the Windows platform, the generated JavaScript from Ceylon JS projects usees \ as the path separator in the require statements for requiring JS module files.

This leads to the following example line, which is broken since "" is a JS escape character:

var m$3=m$1.npm$req('leftPad','left-pad\index.js',require);

Which causes a SyntaxError when attempting to run the Ceylon JS project module:

SyntaxError: Unexpected token ILLEGAL
    at Object.exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:513:28)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at repl:1:9
    at REPLServer.defaultEval (repl.js:272:27)

Is this a bug?

I’m pretty sure it is. The compile-time platform isn’t even necessarily the same as the run-time platform, so there’s no reason to use a different path separator – that’s something that the require function needs to sort out IMO.

I have a possible fix ready (EDIT: now in #6824), but I can’t test it myself, because I don’t have access to a Windows box.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant