Skip to content

Commit

Permalink
fix: normalize path on windows. fixes #278 (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 authored Jan 7, 2019
1 parent 98a038b commit c9c9a79
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
"@babel/register": "^7.0.0",
"cosmiconfig": "^5.0.7",
"dedent": "^0.7.0",
"glob": "^7.1.3",
"cosmiconfig": "^5.0.7",
"loader-utils": "^1.1.0",
"mkdirp": "^0.5.1",
"normalize-path": "^3.0.0",
"postcss": "^7.0.2",
"react-is": "^16.5.1",
"rollup-pluginutils": "^2.3.3",
Expand Down
10 changes: 4 additions & 6 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env node

/* @flow */

const path = require('path');
const normalize = require('normalize-path');
const fs = require('fs');
const mkdirp = require('mkdirp');
const glob = require('glob');
Expand Down Expand Up @@ -100,10 +99,9 @@ function processFiles(files: string[], options: Options) {
path.relative(options.sourceRoot, filename)
);

const requireStatement = `\nrequire('${path.relative(
path.dirname(inputFilename),
outputFilename
)}');`;
const requireStatement = `\nrequire('${normalize(
path.relative(path.dirname(inputFilename), outputFilename)
)}');\n`;

const inputContent = fs.readFileSync(inputFilename, 'utf-8');

Expand Down
3 changes: 2 additions & 1 deletion src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const normalize = require('normalize-path');
/* $FlowFixMe */
const Module = require('module');
const loaderUtils = require('loader-utils');
Expand Down Expand Up @@ -72,7 +73,7 @@ module.exports = function loader(content: string, inputSourceMap: ?Object) {

this.callback(
null,
`${result.code}\n\nrequire("${outputFilename}")`,
`${result.code}\n\nrequire("${normalize(outputFilename)}")`,
result.sourceMap
);
return;
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6019,6 +6019,11 @@ normalize-path@^2.0.0, normalize-path@^2.0.1, normalize-path@^2.1.1:
dependencies:
remove-trailing-separator "^1.0.1"

normalize-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==

normalize-url@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-2.0.1.tgz#835a9da1551fa26f70e92329069a23aa6574d7e6"
Expand Down

0 comments on commit c9c9a79

Please sign in to comment.