Skip to content

Commit ff4f8d1

Browse files
author
Arindam Bose
authored
Fix build, bundling and distribution issues (#1032)
- Fix `package.json` main not pointing to dist - Fix node builtins not being shimmed and treeshaken out out
1 parent 2412b28 commit ff4f8d1

15 files changed

+299
-24
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"homepage": "https://github.com/mapbox/mapbox-gl-draw",
66
"author": "mapbox",
77
"license": "ISC",
8-
"main": "index.js",
8+
"main": "dist/mapbox-gl-draw.js",
99
"browser": "dist/mapbox-gl-draw.js",
1010
"style": "dist/mapbox-gl-draw.css",
1111
"browserify": {
@@ -77,6 +77,7 @@
7777
"opener": "^1.4.1",
7878
"rollup": "^1.27.13",
7979
"rollup-plugin-commonjs": "^10.1.0",
80+
"rollup-plugin-node-builtins": "^2.1.2",
8081
"rollup-plugin-terser": "^5.1.3",
8182
"sinon": "^7.5.0",
8283
"st": "^2.0.0",
@@ -86,7 +87,7 @@
8687
"unassertify": "^2.0.3"
8788
},
8889
"peerDependencies": {
89-
"mapbox-gl": ">=0.27.0 <2.0.0"
90+
"mapbox-gl": ">=0.27.0"
9091
},
9192
"dependencies": {
9293
"@mapbox/geojson-area": "^0.2.1",

rollup.config.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import buble from '@rollup/plugin-buble';
77
import {terser} from 'rollup-plugin-terser';
88
import resolve from '@rollup/plugin-node-resolve';
99
import commonjs from 'rollup-plugin-commonjs';
10+
import builtins from 'rollup-plugin-node-builtins';
1011

1112
export default {
1213
input: ['index.js'],
@@ -18,12 +19,6 @@ export default {
1819
indent: false
1920
},
2021
treeshake: true,
21-
external: [
22-
// geojsonlint-lines has a main function that requires the path and fs module.
23-
// We never call it.
24-
'fs',
25-
'path'
26-
],
2722
plugins: [
2823
replace({
2924
'process.env.NODE_ENV': "'browser'"
@@ -32,8 +27,9 @@ export default {
3227
minified ? terser() : false,
3328
resolve({
3429
browser: true,
35-
preferBuiltins: false
30+
preferBuiltins: true
3631
}),
32+
builtins(),
3733
commonjs({
3834
// global keyword handling causes Webpack compatibility issues, so we disabled it:
3935
// https://github.com/mapbox/mapbox-gl-js/pull/6956

test/api.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import test from 'tape';
33
import spy from 'sinon/lib/sinon/spy'; // avoid babel-register-related error by importing only spy
44
import * as Constants from '../src/constants';
5-
import MapboxDraw from '../';
5+
import MapboxDraw from '../index';
66
import createMap from './utils/create_map';
77
import getGeoJSON from './utils/get_geojson';
88
import setupAfterNextRender from './utils/after_next_render';

test/direct_select.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint no-shadow:[0] */
22
import turfCentroid from '@turf/centroid';
33
import test from 'tape';
4-
import MapboxDraw from '../';
4+
import MapboxDraw from '../index';
55
import click from './utils/mouse_click';
66
import tap from './utils/touch_tap';
77
import getGeoJSON from './utils/get_geojson';

test/draw_line_string.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'tape';
22
import xtend from 'xtend';
3-
import MapboxDraw from '../';
3+
import MapboxDraw from '../index';
44
import mouseClick from './utils/mouse_click';
55
import touchTap from './utils/touch_tap';
66
import createMap from './utils/create_map';

test/draw_point.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'tape';
22
import xtend from 'xtend';
3-
import MapboxDraw from '../';
3+
import MapboxDraw from '../index';
44
import mouseClick from './utils/mouse_click';
55
import touchTap from './utils/touch_tap';
66
import createMap from './utils/create_map';

test/draw_polygon.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'tape';
22
import xtend from 'xtend';
3-
import MapboxDraw from '../';
3+
import MapboxDraw from '../index';
44
import createMap from './utils/create_map';
55
import mouseClick from './utils/mouse_click';
66
import touchTap from './utils/touch_tap';

test/interaction_events.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import test from 'tape';
44
import xtend from 'xtend';
55
import spy from 'sinon/lib/sinon/spy'; // avoid babel-register-related error by importing only spy
6-
import MapboxDraw from '../';
6+
import MapboxDraw from '../index';
77
import click from './utils/mouse_click';
88
import createMap from './utils/create_map';
99
import createAfterNextRender from './utils/after_next_render';

test/line_string.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test from 'tape';
22
import spy from 'sinon/lib/sinon/spy'; // avoid babel-register-related error by importing only spy
33
import Feature from '../src/feature_types/feature';
44
import LineString from '../src/feature_types/line_string';
5-
import MapboxDraw from '../';
5+
import MapboxDraw from '../index';
66
import createFeature from './utils/create_feature';
77
import getPublicMemberKeys from './utils/get_public_member_keys';
88
import createMockCtx from './utils/create_mock_feature_context';

test/options.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint no-shadow:[0] */
22
import test from 'tape';
3-
import MapboxDraw from '../';
3+
import MapboxDraw from '../index';
44
import modes from '../src/modes/index';
55
import styleWithSourcesFixture from './fixtures/style_with_sources.json';
66

test/point.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test from 'tape';
22
import spy from 'sinon/lib/sinon/spy'; // avoid babel-register-related error by importing only spy
33
import Feature from '../src/feature_types/feature';
44
import Point from '../src/feature_types/point';
5-
import MapboxDraw from '../';
5+
import MapboxDraw from '../index';
66
import createFeature from './utils/create_feature';
77
import getPublicMemberKeys from './utils/get_public_member_keys';
88
import createMockCtx from './utils/create_mock_feature_context';

test/polygon.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test from 'tape';
22
import spy from 'sinon/lib/sinon/spy'; // avoid babel-register-related error by importing only spy
33
import Feature from '../src/feature_types/feature';
44
import Polygon from '../src/feature_types/polygon';
5-
import MapboxDraw from '../';
5+
import MapboxDraw from '../index';
66
import createFeature from './utils/create_feature';
77
import getPublicMemberKeys from './utils/get_public_member_keys';
88
import createMockCtx from './utils/create_mock_feature_context';

test/simple_select.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint no-shadow:[0] */
22
import test from 'tape';
3-
import MapboxDraw from '../';
3+
import MapboxDraw from '../index';
44
import spy from 'sinon/lib/sinon/spy'; // avoid babel-register-related error by importing only spy
55
import setupAfterNextRender from './utils/after_next_render';
66
import makeMouseEvent from './utils/make_mouse_event';

test/static.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint no-shadow:[0] */
22
import test from 'tape';
3-
import MapboxDraw from '../';
3+
import MapboxDraw from '../index';
44
import spy from 'sinon/lib/sinon/spy'; // avoid babel-register-related error by importing only spy
55
import setupAfterNextRender from './utils/after_next_render';
66
import makeMouseEvent from './utils/make_mouse_event';

0 commit comments

Comments
 (0)