Skip to content

Commit eb9db42

Browse files
authored
ESM Build fixes (#125)
1 parent 038c39a commit eb9db42

3 files changed

Lines changed: 76 additions & 13 deletions

File tree

demo/js/planning.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ interactiveMap.on('app:ready', function (e) {
136136
})
137137

138138
interactiveMap.on('map:ready', function (e) {
139+
console.log(e)
140+
139141
// Add datasets and map features
140142
const dataset = getQueryParam('dataset', 'floodzones-presentday')
141143
const mapFeatures = getQueryParam('features')

package.json

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,56 @@
55
"main": "dist/umd/index.js",
66
"module": "dist/esm/index.js",
77
"exports": {
8-
"import": "./dist/esm/index.js",
9-
"require": "./dist/umd/index.js"
8+
".": {
9+
"import": "./dist/esm/index.js",
10+
"require": "./dist/umd/index.js"
11+
},
12+
"./providers/maplibre": {
13+
"import": "./providers/maplibre/dist/esm/index.js",
14+
"require": "./providers/maplibre/dist/umd/index.js"
15+
},
16+
"./providers/open-names": {
17+
"import": "./providers/beta/open-names/dist/esm/index.js",
18+
"require": "./providers/beta/open-names/dist/umd/index.js"
19+
},
20+
"./providers/esri": {
21+
"import": "./providers/beta/esri/dist/esm/index.js"
22+
},
23+
"./plugins/scale-bar": {
24+
"import": "./plugins/beta/scale-bar/dist/esm/index.js",
25+
"require": "./plugins/beta/scale-bar/dist/umd/index.js"
26+
},
27+
"./plugins/use-location": {
28+
"import": "./plugins/beta/use-location/dist/esm/index.js",
29+
"require": "./plugins/beta/use-location/dist/umd/index.js"
30+
},
31+
"./plugins/search": {
32+
"import": "./plugins/search/dist/esm/index.js",
33+
"require": "./plugins/search/dist/umd/index.js"
34+
},
35+
"./plugins/interact": {
36+
"import": "./plugins/interact/dist/esm/index.js",
37+
"require": "./plugins/interact/dist/umd/index.js"
38+
},
39+
"./plugins/datasets": {
40+
"import": "./plugins/beta/datasets/dist/esm/index.js",
41+
"require": "./plugins/beta/datasets/dist/umd/index.js"
42+
},
43+
"./plugins/map-styles": {
44+
"import": "./plugins/beta/map-styles/dist/esm/index.js",
45+
"require": "./plugins/beta/map-styles/dist/umd/index.js"
46+
},
47+
"./plugins/draw-ml": {
48+
"import": "./plugins/beta/draw-ml/dist/esm/index.js",
49+
"require": "./plugins/beta/draw-ml/dist/umd/index.js"
50+
},
51+
"./plugins/draw-es": {
52+
"import": "./plugins/beta/draw-es/dist/esm/index.js"
53+
},
54+
"./plugins/frame": {
55+
"import": "./plugins/beta/frame/dist/esm/index.js",
56+
"require": "./plugins/beta/frame/dist/umd/index.js"
57+
}
1058
},
1159
"type": "module",
1260
"scripts": {
@@ -41,10 +89,14 @@
4189
]
4290
},
4391
"peerDependencies": {
92+
"@arcgis/core": "^4.34.8",
4493
"react": "^19.2.0",
4594
"react-dom": "^19.2.0"
4695
},
4796
"peerDependenciesMeta": {
97+
"@arcgis/core": {
98+
"optional": true
99+
},
48100
"react": {
49101
"optional": true
50102
},
@@ -53,6 +105,7 @@
53105
}
54106
},
55107
"devDependencies": {
108+
"@arcgis/core": "^4.34.8",
56109
"@babel/core": "^7.28.0",
57110
"@babel/preset-env": "^7.28.0",
58111
"@babel/preset-react": "^7.27.1",
@@ -114,7 +167,6 @@
114167
"@turf/bearing": "^7.3.3"
115168
},
116169
"dependencies": {
117-
"@arcgis/core": "^4.34.8",
118170
"@turf/area": "^7.2.0",
119171
"@turf/bearing": "^7.3.3",
120172
"@turf/boolean-disjoint": "^7.3.3",

webpack.esm.mjs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,23 @@ const createESMConfig = (entryName, entryPath, outDir, isCore = false) => {
8686
},
8787
externals: isCore
8888
? {}
89-
: {
90-
react: 'react',
91-
'react-dom': 'react-dom',
92-
'react/jsx-runtime': 'react/jsx-runtime',
93-
preact: 'preact',
94-
'preact/compat': 'preact/compat',
95-
'preact/hooks': 'preact/hooks',
96-
'preact/jsx-runtime': 'preact/jsx-runtime'
97-
},
89+
: [
90+
{
91+
react: 'react',
92+
'react-dom': 'react-dom',
93+
'react/jsx-runtime': 'react/jsx-runtime',
94+
preact: 'preact',
95+
'preact/compat': 'preact/compat',
96+
'preact/hooks': 'preact/hooks',
97+
'preact/jsx-runtime': 'preact/jsx-runtime'
98+
},
99+
({ request }, callback) => {
100+
if (request.startsWith('@arcgis/core')) {
101+
return callback(null, `module ${request}`)
102+
}
103+
return callback()
104+
}
105+
],
98106
module: {
99107
rules: [
100108
{ test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/ },
@@ -119,7 +127,7 @@ const ALL_BUILDS = [
119127
// Providers
120128
{ entryPath: './providers/maplibre/src/index.js', outDir: 'providers/maplibre/dist/esm' },
121129
{ entryPath: './providers/beta/open-names/src/index.js', outDir: 'providers/beta/open-names/dist/esm' },
122-
// { entryPath: './providers/beta/esri/src/index.js', outDir: 'providers/beta/esri/dist/esm' },
130+
{ entryPath: './providers/beta/esri/src/index.js', outDir: 'providers/beta/esri/dist/esm' },
123131

124132
// Plugins
125133
{ entryPath: './plugins/beta/scale-bar/src/index.js', outDir: 'plugins/beta/scale-bar/dist/esm' },
@@ -129,6 +137,7 @@ const ALL_BUILDS = [
129137
{ entryPath: './plugins/beta/datasets/src/index.js', outDir: 'plugins/beta/datasets/dist/esm' },
130138
{ entryPath: './plugins/beta/map-styles/src/index.js', outDir: 'plugins/beta/map-styles/dist/esm' },
131139
{ entryPath: './plugins/beta/draw-ml/src/index.js', outDir: 'plugins/beta/draw-ml/dist/esm' },
140+
{ entryPath: './plugins/beta/draw-es/src/index.js', outDir: 'plugins/beta/draw-es/dist/esm' },
132141
{ entryPath: './plugins/beta/frame/src/index.js', outDir: 'plugins/beta/frame/dist/esm' }
133142
]
134143

0 commit comments

Comments
 (0)