alexisvincent / systemjs-tools

(dev)tools for working with SystemJS
MIT License
43 stars 5 forks source link

Test windows support #8

Open alexisvincent opened 7 years ago

alexisvincent commented 7 years ago

Make sure this works with windows

jhholm commented 7 years ago

Doesn't work out of the box in Windows. Seems to be a problem with directory handling (\ or double \ instead of /). I managed to get stuff working (serve + live reload) with a dirty hack though.

Had to modify dist/config.js (line 40) configs.file = require(path.join.apply(path, ['/'].concat(_toConsumableArray(dir), ['systemjs-tools.js']))).config;

and dist/index.js (line 331) .fileChanged = function (absolutePath) { .events.next({ type: 'file-changed', absolutePath: absolutePath, relativePath: _path2.default.relative(config.directories.root, absolutePath), url: _path2.default.relative(config.directories.baseURL, absolutePath) }); };

The url parameter didn't work. I just hardcoded those values for now.

jhholm commented 7 years ago

This issue still persists in the new version, tested with NPM 6 and 8. The path created for require comes now as e.g /C:/GIT/project/systemjs-tools.js, which doesn't work in Windows. So the problem seems to be that Windows also has drive letters. For now I just do a dirty .slice(1) to the _toConsumableArray(dir) to get the systemjs-tools.js location working.

I'll try to test if I can find a solution that works across all environments.

alexisvincent commented 7 years ago

Awesome thanks, realistically I won’t be able to test windows support so if you are able to that would be awesome!

jhholm commented 7 years ago

For now it seems that if I change the following (config.js line 26 and 30): configs.file = require(path.join('/', ...dir, 'systemjs-tools.js')).config

to configs.file = require(path.join(...dir, 'systemjs-tools.js')).config

directory handling seems to work within Windows. Is the preceding '/' required? The variable dir contains initially process.cwd(), which should already contain the preceding / within Unix environments.

aluanhaddad commented 7 years ago

Thank you for this awesome tool. I want to use it.

My team works on windows.

I tried making the changes discussed but I was unable to get it working. When I run systemjs serve, I get

:: exiting :: couldn't find a valid systemjs-tools config

I am using the config file sample from the README.

jhholm commented 7 years ago

I created a fork with the aforementioned fixes https://github.com/jhholm/systemjs-tools

You can try that if you want.

aluanhaddad commented 7 years ago

Trying it, thank you!

aluanhaddad commented 7 years ago

@jhholm thanks for creating that fork. Unfortunately, I still receive the same error

:: exiting :: couldn't find a valid systemjs-tools config

It is possible I am doing something incredibly bone-headed.

I am running Windows 10 pro 64bit under NodeJS 8.7.0 and npm@5.5.1.

I installed the package using

npm install --global jhholm/systemjs-tools#master

I then created the configuration file mentioned in README systemjs-tools.js

fs = require('fs');

// Specify keys for localhost
module.exports.config.serve.keys = {
  key: fs.readFileSync('localhost.key', 'utf-8'),
  cert: fs.readFileSync('localhost.crt', 'utf-8'),
  ca: fs.readFileSync('localhost.key', 'utf-8'),
};
module.exports.config.channel = {
  keys: module.exports.config.serve.keys
};

Then from the that file's containing directory, I ran

~C:\Source\project> systemjs serve

Thanks for your assistance.

jhholm commented 7 years ago

I tested with your config file, and I get the same error. I suppose the config file might be the issue. E.g. this should work.

var fs = require("fs");

module.exports.config = {
    serve: {
        port: 8080,
        keys: {
            key: fs.readFileSync('localhost.key', 'utf-8'),
            cert: fs.readFileSync('localhost.crt', 'utf-8'),
            ca: fs.readFileSync('localhost.key', 'utf-8'),
        }
}