Compare commits

...

5 Commits

Author SHA1 Message Date
Rich Harris
cd91bf2ca4 -> v0.2.4 2017-12-20 16:33:54 -05:00
Rich Harris
7466e8da82 -> v0.2.3 2017-12-20 09:31:51 -05:00
Rich Harris
463307db86 pass URL to 404 handler 2017-12-20 08:29:28 -05:00
Rich Harris
2a68394dce Merge pull request #31 from sveltejs/possible-windows-fix-3
posixify import paths
2017-12-20 08:28:32 -05:00
Rich Harris
c8fe0679ae posixify import paths 2017-12-19 20:48:44 -05:00
4 changed files with 22 additions and 7 deletions

View File

@@ -1,5 +1,14 @@
# sapper changelog # sapper changelog
## 0.2.4
* Posixify path to HMR client
## 0.2.3
* Posixify import paths, even on Windows ([#31](https://github.com/sveltejs/sapper/pull/31))
* Pass `url` to 404 handler
## 0.2.2 ## 0.2.2
* Create destination directory when building, don't assume it's already there from dev mode * Create destination directory when building, don't assume it's already there from dev mode

View File

@@ -179,7 +179,7 @@ function not_found(req, res) {
title: 'Not found', title: 'Not found',
status: 404, status: 404,
method: req.method, method: req.method,
url url: req.url
})); }));
} }

View File

@@ -3,6 +3,10 @@ const path = require('path');
const route_manager = require('../route_manager.js'); const route_manager = require('../route_manager.js');
const { src, dest, server_routes, dev } = require('../config.js'); const { src, dest, server_routes, dev } = require('../config.js');
function posixify(file) {
return file.replace(/[\/\\]/g, '/');
}
module.exports = function create_app() { module.exports = function create_app() {
const { routes } = route_manager; const { routes } = route_manager;
@@ -17,18 +21,19 @@ module.exports = function create_app() {
'{}' : '{}' :
`{ ${route.dynamic.map((part, i) => `${part}: match[${i + 1}]`).join(', ') } }`; `{ ${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(', ') .join(', ')
}]`; }]`;
let main = template 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(/__routes__/g, code)
.replace(/__dev__/g, String(dev)); .replace(/__dev__/g, String(dev));
if (dev) { if (dev) {
const hmr_client = require.resolve(`webpack-hot-middleware/client`); const hmr_client = posixify(require.resolve(`webpack-hot-middleware/client`));
main += `\n\nimport('${hmr_client}?path=/__webpack_hmr&timeout=20000'); if (module.hot) module.hot.accept();` main += `\n\nimport('${hmr_client}?path=/__webpack_hmr&timeout=20000'); if (module.hot) module.hot.accept();`
} }
@@ -44,9 +49,10 @@ module.exports = function create_app() {
function create_server_routes() { function create_server_routes() {
const imports = routes const imports = routes
.map(route => { .map(route => {
const file = posixify(`${src}/${route.file}`);
return route.type === 'page' ? return route.type === 'page' ?
`import ${route.id} from '${src}/${route.file}';` : `import ${route.id} from '${file}';` :
`import * as ${route.id} from '${src}/${route.file}';`; `import * as ${route.id} from '${file}';`;
}) })
.join('\n'); .join('\n');

View File

@@ -1,6 +1,6 @@
{ {
"name": "sapper", "name": "sapper",
"version": "0.2.2", "version": "0.2.4",
"description": "Military-grade apps, engineered by Svelte", "description": "Military-grade apps, engineered by Svelte",
"main": "lib/index.js", "main": "lib/index.js",
"bin": { "bin": {