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 for building/bundling #10

Open
wants to merge 1 commit 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.tgz
bundle.*.js
node_modules/
10 changes: 0 additions & 10 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion free.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ffs/wizard module
module.exports = function(presets) {
export function free(presets) {
var freeFormQuery = {};
if (!presets) presets = {};

Expand Down
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var parser = require("./parser.js");
import {parse} from "./parser.js";
import {free} from "./free.js";
var freeFormQuery; // todo: refactor this!

// todo: normalization -> node module?
Expand Down Expand Up @@ -44,7 +45,7 @@ function normalize(query) {
return normalized_query;
}

module.exports = function wizard(search, options) {
export default function wizard(search, options) {
var defaults = {
comment: true,
outputMode: "geom", // "recursive", "recursive_meta", out <*> ("geom", "ids", …)
Expand All @@ -71,9 +72,9 @@ module.exports = function wizard(search, options) {
var parsedQuery;

try {
parsedQuery = parser.parse(search);
parsedQuery = parse(search);
} catch(e) {
console.error("couldn't parse wizard input");
console.error("couldn't parse wizard input", e);
return false;
}

Expand Down Expand Up @@ -291,7 +292,7 @@ module.exports = function wizard(search, options) {
// todo: looks like some code duplication here could be reduced by refactoring
if (cond_query.query === "free form") {
// eventually load free form query module
if (!freeFormQuery) freeFormQuery = require('./free')(options.freeFormPresets);
if (!freeFormQuery) freeFormQuery = free(options.freeFormPresets);
var ffs_clause = freeFormQuery.get_query_clause(cond_query);
if (ffs_clause === false) {
console.error("Couldn't find preset for free form input: "+cond_query.free)
Expand Down
2 changes: 1 addition & 1 deletion overpass-wizard
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var argv = require('yargs')
fs = require('fs'),
concat = require('concat-stream'),
expand = require('./expand'),
wizard = require('./');
wizard = require('./bundle.umd');

if (argv.version) {
return process.stdout.write(require('./package.json').version+'\n');
Expand Down
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"name": "overpass-wizard",
"version": "0.0.9",
"description": "Human friendly way to generate Overpass API queries",
"main": "index.js",
"main": "bundle.umd.js",
"scripts": {
"build": "pegjs -O size < wizard.pegjs > parser.js",
"pretest": "npm ls --depth=Infinity > /dev/null",
"test": "npm run test-lib",
"build": "npm run build:pegjs && npm run build:rollup && npm run build:rollup:min",
"build:pegjs": "pegjs --format es --optimize size < wizard.pegjs > parser.js",
"build:rollup": "rollup --config",
"build:rollup:min": "rollup --config --environment NODE_ENV:production",
"test": "npm run build && npm run test-lib",
"test-lib": "mocha -R spec"
},
"bin": {
Expand Down Expand Up @@ -36,7 +38,9 @@
"devDependencies": {
"expect.js": "^0.3.1",
"mocha": "^7.0.1",
"pegjs": "^0.10.0"
"pegjs": "pegjs/pegjs#6939d1eb8d4b36df9be08696b75d2ca526845794",
"rollup": "^1.30.1",
"rollup-plugin-terser": "^5.2.0"
},
"browser": {
"request-promise": false
Expand Down
Loading