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

Commit

Permalink
Merge pull request #31 from sveltejs/possible-windows-fix-3
Browse files Browse the repository at this point in the history
posixify import paths
  • Loading branch information
Rich-Harris authored Dec 20, 2017
2 parents 51d45cf + c8fe067 commit 2a68394
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/utils/create_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const path = require('path');
const route_manager = require('../route_manager.js');
const { src, dest, server_routes, dev } = require('../config.js');

function posixify(file) {
return file.replace(/[\/\\]/g, '/');
}

module.exports = function create_app() {
const { routes } = route_manager;

Expand All @@ -17,13 +21,14 @@ module.exports = function create_app() {
'{}' :
`{ ${route.dynamic.map((part, i) => `${part}: match[${i + 1}]`).join(', ') } }`;
return `{ pattern: ${route.pattern}, params: match => (${params}), load: () => import(/* webpackChunkName: "${route.id}" */ '${src}/${route.file}') }`
const file = posixify(`${src}/${route.file}`);
return `{ pattern: ${route.pattern}, params: match => (${params}), load: () => import(/* webpackChunkName: "${route.id}" */ '${file}') }`
})
.join(', ')
}]`;

let main = template
.replace(/__app__/g, path.resolve(__dirname, '../../runtime/app.js'))
.replace(/__app__/g, posixify(path.resolve(__dirname, '../../runtime/app.js')))
.replace(/__routes__/g, code)
.replace(/__dev__/g, String(dev));

Expand All @@ -44,9 +49,10 @@ module.exports = function create_app() {
function create_server_routes() {
const imports = routes
.map(route => {
const file = posixify(`${src}/${route.file}`);
return route.type === 'page' ?
`import ${route.id} from '${src}/${route.file}';` :
`import * as ${route.id} from '${src}/${route.file}';`;
`import ${route.id} from '${file}';` :
`import * as ${route.id} from '${file}';`;
})
.join('\n');

Expand Down

0 comments on commit 2a68394

Please sign in to comment.