Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rollup #94

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
module.exports = {
"extends": "@mapbox/eslint-config-mapbox"
"extends": [
"@mapbox/eslint-config-mapbox/import"
],
"parserOptions": {
"sourceType": "module"
},
"env": {
"node": true,
"browser": true,
}
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
*.mbtiles
public/*
!public/index.html
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
examples/
src/
test/
rollup.config.js
.eslintrc.js
.travis.yml
5 changes: 3 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

/* eslint-disable no-console */
'use strict';


const argv = require('minimist')(process.argv.slice(2), {
boolean: ['n', 'quiet', 'q']
Expand Down Expand Up @@ -29,7 +29,8 @@ if (argv.version || argv.v) {
try {
mbtiles.forEach((f) => { fs.statSync(f).isFile(); });
} catch (e) {
return console.error(e);
console.error(e);
process.exit(1);
}

argv.basemap = argv.basemap || argv.base || argv.map || 'dark';
Expand Down
17 changes: 7 additions & 10 deletions mbview.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-console */
'use strict';


const express = require('express');

const app = express();
const MBTiles = require('@mapbox/mbtiles');
const q = require('d3-queue').queue();
Expand All @@ -10,10 +11,10 @@ const objectAssign = require('object-assign');

app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use(express.static(__dirname + '/public'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea where it pulls public from without setting _dirname + '/... ?

I just opened #96 which would conflict with this change, but without making the change mbview was broken for me.

Copy link
Author

@SKalt SKalt Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess would express.static looks for "public" in your current working directory.

I couldn't find any docs with a definite answer.

None of

Copy link
Author

@SKalt SKalt Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a single directory with that name, even in node_modules. You're definitely safe to nuke that line.

# in root of repo
docker run -it $(pwd):/root node:12-alpine sh
cd && rm -rf ./node_modules && npm ci && find . -type d -name public
echo $? && exit 


module.exports = {

module.exports = {
/**
* Load a tileset and return a reference with metadata
* @param {object} file reference to the tileset
Expand Down Expand Up @@ -57,13 +58,9 @@ module.exports = {

listen: function (config, onListen) {
const format = config.tiles._info.format;

app.get('/', (req, res) => {
if (format === 'pbf') {
res.render('vector', config);
} else {
res.render('raster', config);
}
app.get('/config.js', (req, res) => {
res.type('js');
res.render('config', config);
});

app.get('/:source/:z/:x/:y.' + format, (req, res) => {
Expand Down
Loading