Skip to content

Commit

Permalink
Merge pull request #526 from Esri/mg/update-pure-ESM-approach
Browse files Browse the repository at this point in the history
chore: update map and coding component README with pure ESM approach
  • Loading branch information
manugadde authored Aug 9, 2024
2 parents 097b586 + 9f0a9be commit 776435c
Show file tree
Hide file tree
Showing 52 changed files with 172 additions and 39 deletions.
20 changes: 18 additions & 2 deletions component-samples/coding-components/samples/react/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Coding components React using Vite sample

📁 **[Click here to download this directory as a ZIP file](https://esri.github.io/jsapi-resources/zips/coding-components-sample-react.zip)
📁 **[Click here to download this directory as a ZIP file](https://esri.github.io/jsapi-resources/zips/coding-components-sample-react.zip)** 📁

This repository showcases how to integrate the coding components with [React](https://react.dev/).

Expand All @@ -10,4 +10,20 @@ The project was created using [`yarn create vite`](https://vitejs.dev/guide/#sca

Run `npm install` and then start adding modules.

For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.
For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.

***Note:*** This sample demonstrates the recommended pattern for using components from the ArcGIS Map SDK for JavaScript by individually loading components.

### Loading All Components
The JavaScript Maps SDK also offers a convenience pattern useful for quick testing and prototyping. You can register all components at once using the following approach:

```
// Replace the individual imports with defineCustomElements()
import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
import { defineCustomElements as defineCodingElements } from "@arcgis/coding-components/dist/loader";
defineCalciteElements(window, { resourcesUrl: "https://js.arcgis.com/calcite-components/2.8.5/assets" });
defineCodingElements(window, { resourcesUrl: "https://js.arcgis.com/coding-components/4.30/assets" });
```

For more details on using the SDK, please refer to the [ArcGIS Maps SDK for JavaScript documentation](https://developers.arcgis.com/javascript/latest/get-started-overview/).
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import { useEffect, useCallback, useState } from "react";

// Import React components of the components used in this sample
import { ArcgisArcadeEditor } from "@arcgis/coding-components-react";
import { CalciteScrim } from "@esri/calcite-components-react";

Expand Down
12 changes: 7 additions & 5 deletions component-samples/coding-components/samples/react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import React from "react";
import ReactDOM from "react-dom/client";

import ArcadeEditor from "./components/ArcadeEditor";
import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
import { defineCustomElements as defineCodingElements } from "@arcgis/coding-components/dist/loader";

// define custom elements in the browser, and load the assets from the CDN
defineCodingElements(window, { resourcesUrl: "https://js.arcgis.com/coding-components/4.30/assets" });
defineCalciteElements(window, { resourcesUrl: "https://js.arcgis.com/calcite-components/2.8.5/assets" });
// Individual imports for each component used in this sample
import "@arcgis/coding-components/dist/components/arcgis-arcade-editor";
import "@esri/calcite-components/dist/components/calcite-scrim";

// Set the asset path for calcite components
import { setAssetPath as setCalciteComponentsAssetPath } from '@esri/calcite-components/dist/components';
setCalciteComponentsAssetPath("https://js.arcgis.com/calcite-components/2.8.0/assets");

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
Expand Down
18 changes: 17 additions & 1 deletion component-samples/coding-components/samples/vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,20 @@ The project was created using [`yarn create vite`](https://vitejs.dev/guide/#sca

Run `npm install` and then start adding modules.

For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.
For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.

***Note:*** This sample demonstrates the recommended pattern for using components from the ArcGIS Map SDK for JavaScript by individually loading components.

### Loading All Components
The JavaScript Maps SDK also offers a convenience pattern useful for quick testing and prototyping. You can register all components at once using the following approach:

```
// Replace the individual imports with defineCustomElements()
import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
import { defineCustomElements as defineCodingElements } from "@arcgis/coding-components/dist/loader";
defineCalciteElements(window, { resourcesUrl: "https://js.arcgis.com/calcite-components/2.8.5/assets" });
defineCodingElements(window, { resourcesUrl: "https://js.arcgis.com/coding-components/4.30/assets" });
```

For more details on using the SDK, please refer to the [ArcGIS Maps SDK for JavaScript documentation](https://developers.arcgis.com/javascript/latest/get-started-overview/).
13 changes: 8 additions & 5 deletions component-samples/coding-components/samples/vite/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ import "./style.css"; // Arcade editor styles

import { loadData } from "./load-data";

import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
import { defineCustomElements as defineCodingElements } from "@arcgis/coding-components/dist/loader";
// Individual imports for each component
import { setArcgisAssetPath as setCodingComponentsAssetPath } from "@arcgis/coding-components/dist/components";
import "@arcgis/coding-components/dist/components/arcgis-arcade-editor";

// define custom elements in the browser, and load the assets from the CDN
defineCalciteElements(window, { resourcesUrl: "https://js.arcgis.com/calcite-components/2.8.5/assets" });
defineCodingElements(window, { resourcesUrl: "https://js.arcgis.com/coding-components/4.30/assets" });
import { setAssetPath as setCalciteComponentsAssetPath } from '@esri/calcite-components/dist/components';
import "@esri/calcite-components/dist/components/calcite-scrim";

setCodingComponentsAssetPath("https://js.arcgis.com/coding-components/4.30/assets");
setCalciteComponentsAssetPath("https://js.arcgis.com/calcite-components/2.8.0/assets");

(async () => {
// Get the Arcade editor element
Expand Down
16 changes: 16 additions & 0 deletions component-samples/coding-components/samples/vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,19 @@ This sample should help get you started developing with Vue 3 in Vite. The sampl
Run `npm install` and then start adding modules.

For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.

***Note:*** This sample demonstrates the recommended pattern for using components from the ArcGIS Map SDK for JavaScript by individually loading components.

### Loading All Components
The JavaScript Maps SDK also offers a convenience pattern useful for quick testing and prototyping. You can register all components at once using the following approach:

```
// Replace the individual imports with defineCustomElements()
import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
import { defineCustomElements as defineCodingElements } from "@arcgis/coding-components/dist/loader";
defineCalciteElements(window, { resourcesUrl: "https://js.arcgis.com/calcite-components/2.8.5/assets" });
defineCodingElements(window, { resourcesUrl: "https://js.arcgis.com/coding-components/4.30/assets" });
```

For more details on using the SDK, please refer to the [ArcGIS Maps SDK for JavaScript documentation](https://developers.arcgis.com/javascript/latest/get-started-overview/).
13 changes: 8 additions & 5 deletions component-samples/coding-components/samples/vue/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ import "./assets/main.css"; // App style
import { createApp } from "vue";
import App from "./App.vue";

import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
import { defineCustomElements as defineCodingElements } from "@arcgis/coding-components/dist/loader";
// Individual imports for each component
import { setArcgisAssetPath as setCodingComponentsAssetPath } from "@arcgis/coding-components/dist/components";
import "@arcgis/coding-components/dist/components/arcgis-arcade-editor";

// define custom elements in the browser, and load the assets from the CDN
defineCalciteElements(window, { resourcesUrl: "https://js.arcgis.com/calcite-components/2.8.5/assets" });
defineCodingElements(window, { resourcesUrl: "https://js.arcgis.com/coding-components/4.30/assets" });
import { setAssetPath as setCalciteComponentsAssetPath } from '@esri/calcite-components/dist/components';
import "@esri/calcite-components/dist/components/calcite-scrim";

setCodingComponentsAssetPath("https://js.arcgis.com/coding-components/4.30/assets");
setCalciteComponentsAssetPath("https://js.arcgis.com/calcite-components/2.8.0/assets");

createApp(App).mount('#app');
14 changes: 14 additions & 0 deletions component-samples/coding-components/samples/webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@ Run `npm install` and then start adding modules.

For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.

***Note:*** This sample demonstrates the recommended pattern for using components from the ArcGIS Map SDK for JavaScript by individually loading components.

### Loading All Components
The JavaScript Maps SDK also offers a convenience pattern useful for quick testing and prototyping. You can register all components at once using the following approach:

```
// Replace the individual imports with defineCustomElements()
import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
import { defineCustomElements as defineCodingElements } from "@arcgis/coding-components/dist/loader";
defineCalciteElements(window, { resourcesUrl: "https://js.arcgis.com/calcite-components/2.8.5/assets" });
defineCodingElements(window, { resourcesUrl: "https://js.arcgis.com/coding-components/4.30/assets" });
```

For more details on using the SDK, please refer to the [ArcGIS Maps SDK for JavaScript documentation](https://developers.arcgis.com/javascript/latest/get-started-overview/).
13 changes: 8 additions & 5 deletions component-samples/coding-components/samples/webpack/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
* limitations under the License.
*/

import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
import { defineCustomElements as defineCodingElements } from "@arcgis/coding-components/dist/loader";
// Individual imports for each component
import { setArcgisAssetPath as setCodingComponentsAssetPath } from "@arcgis/coding-components/dist/components";
import "@arcgis/coding-components/dist/components/arcgis-arcade-editor";

// define custom elements in the browser, and load the assets from the CDN
defineCalciteElements(window, { resourcesUrl: "https://js.arcgis.com/calcite-components/2.8.5/assets" });
defineCodingElements(window, { resourcesUrl: "https://js.arcgis.com/coding-components/4.30/assets" });
import { setAssetPath as setCalciteComponentsAssetPath } from '@esri/calcite-components/dist/components';
import "@esri/calcite-components/dist/components/calcite-scrim";

setCodingComponentsAssetPath("https://js.arcgis.com/coding-components/4.30/assets");
setCalciteComponentsAssetPath("https://js.arcgis.com/calcite-components/2.8.0/assets");

import { loadData } from "./load-data";

Expand Down
15 changes: 14 additions & 1 deletion component-samples/map-components/samples/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@ The project was created using [`yarn create vite`](https://vitejs.dev/guide/#sca

Run `npm install` and then start adding modules.

For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.
For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.

***Note:*** This sample demonstrates the recommended pattern for using components from the ArcGIS Map SDK for JavaScript by individually loading components.

### Loading All Components
The JavaScript Maps SDK also offers a convenience pattern useful for quick testing and prototyping. You can register all components at once using the following approach:

```
// Replace the individual imports with defineCustomElements()
import { defineCustomElements } from "@arcgis/map-components/dist/loader";
defineCustomElements(window, { resourcesUrl: "https://js.arcgis.com/map-components/4.30/assets" });
```

For more details on using the SDK, please refer to the [ArcGIS Maps SDK for JavaScript documentation](https://developers.arcgis.com/javascript/latest/get-started-overview/).
7 changes: 4 additions & 3 deletions component-samples/map-components/samples/react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";

// Individual imports for each component used in this sample
import "@arcgis/map-components/dist/components/arcgis-map";
import "@arcgis/map-components/dist/components/arcgis-legend";
import "@arcgis/map-components/dist/components/arcgis-search";
import { ArcgisMap, ArcgisSearch, ArcgisLegend } from "@arcgis/map-components-react";
import { defineCustomElements as defineMapElements } from "@arcgis/map-components/dist/loader";

defineMapElements(window, { resourcesUrl: "https://js.arcgis.com/map-components/4.30/assets" });

const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);
root.render(
Expand Down
15 changes: 14 additions & 1 deletion component-samples/map-components/samples/vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@ The project was created using [`npm create vite`](https://vitejs.dev/guide/#scaf

Run `npm install` and then start adding modules.

For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.
For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.

***Note:*** This sample demonstrates the recommended pattern for using components from the ArcGIS Map SDK for JavaScript by individually loading components.

### Loading All Components
The JavaScript Maps SDK also offers a convenience pattern useful for quick testing and prototyping. You can register all components at once using the following approach:

```
// Replace the individual imports with defineCustomElements()
import { defineCustomElements } from "@arcgis/map-components/dist/loader";
defineCustomElements(window, { resourcesUrl: "https://js.arcgis.com/map-components/4.30/assets" });
```

For more details on using the SDK, please refer to the [ArcGIS Maps SDK for JavaScript documentation](https://developers.arcgis.com/javascript/latest/get-started-overview/).
10 changes: 6 additions & 4 deletions component-samples/map-components/samples/vite/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import "./styles.css";
// Lazy loading ESM
import { defineCustomElements } from "@arcgis/map-components/dist/loader";
defineCustomElements(window, { resourcesUrl: "https://js.arcgis.com/map-components/4.30/assets" });

// Individual imports for each component
import "@arcgis/map-components/dist/components/arcgis-map";
import "@arcgis/map-components/dist/components/arcgis-legend";
import "@arcgis/map-components/dist/components/arcgis-search";

const mapElement = document.querySelector('arcgis-map');
mapElement.addEventListener('arcgisViewReadyChange', event => {
mapElement.addEventListener('arcgisViewReadyChange', event => {
console.log('MapView ready', event);
});
15 changes: 14 additions & 1 deletion component-samples/map-components/samples/vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@ The project was created using [`npm create vite`](https://vitejs.dev/guide/#scaf

Run `npm install` and then start adding modules.

For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.
For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.

***Note:*** This sample demonstrates the recommended pattern for using components from the ArcGIS Map SDK for JavaScript by individually loading components.

### Loading All Components
The JavaScript Maps SDK also offers a convenience pattern useful for quick testing and prototyping. You can register all components at once using the following approach:

```
// Replace the individual imports with defineCustomElements()
import { defineCustomElements } from "@arcgis/map-components/dist/loader";
defineCustomElements(window, { resourcesUrl: "https://js.arcgis.com/map-components/4.30/assets" });
```

For more details on using the SDK, please refer to the [ArcGIS Maps SDK for JavaScript documentation](https://developers.arcgis.com/javascript/latest/get-started-overview/).
7 changes: 5 additions & 2 deletions component-samples/map-components/samples/vue/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<script setup>
import Map from "@/components/Map.vue";
import { defineCustomElements } from "@arcgis/map-components/dist/loader";
defineCustomElements(window, { resourcesUrl: "https://js.arcgis.com/map-components/4.30/assets" });
// Individual imports for each component
import "@arcgis/map-components/dist/components/arcgis-map";
import "@arcgis/map-components/dist/components/arcgis-legend";
import "@arcgis/map-components/dist/components/arcgis-search";
</script>

<template>
Expand Down
15 changes: 14 additions & 1 deletion component-samples/map-components/samples/webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@ This repository showcases how to integrate the map components using webpack.

Run `npm install` and then start adding modules.

For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.
For a list of all available `npm` commands see `scripts` in `package.json`, e.g. `npm run build`.

***Note:*** This sample demonstrates the recommended pattern for using components from the ArcGIS Map SDK for JavaScript by individually loading components.

### Loading All Components
The JavaScript Maps SDK also offers a convenience pattern useful for quick testing and prototyping. You can register all components at once using the following approach:

```
// Replace the individual imports with defineCustomElements()
import { defineCustomElements } from "@arcgis/map-components/dist/loader";
defineCustomElements(window, { resourcesUrl: "https://js.arcgis.com/map-components/4.30/assets" });
```

For more details on using the SDK, please refer to the [ArcGIS Maps SDK for JavaScript documentation](https://developers.arcgis.com/javascript/latest/get-started-overview/).
7 changes: 4 additions & 3 deletions component-samples/map-components/samples/webpack/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
* limitations under the License.
*/

// Lazy loading ESM
import { defineCustomElements } from "@arcgis/map-components/dist/loader";
defineCustomElements(window, { resourcesUrl: "https://js.arcgis.com/map-components/4.30/assets" });
// Individual imports for each component
import "@arcgis/map-components/dist/components/arcgis-map";
import "@arcgis/map-components/dist/components/arcgis-legend";
import "@arcgis/map-components/dist/components/arcgis-search";

const mapElement = document.querySelector("arcgis-map");
mapElement.addEventListener("arcgisViewReadyChange", (event) => {
Expand Down
Binary file modified zips/charts-components-sample-angular.zip
Binary file not shown.
Binary file modified zips/charts-components-sample-cdn.zip
Binary file not shown.
Binary file modified zips/charts-components-sample-react.zip
Binary file not shown.
Binary file modified zips/charts-components-sample-vite.zip
Binary file not shown.
Binary file modified zips/charts-components-sample-vue.zip
Binary file not shown.
Binary file modified zips/charts-components-sample-webpack.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified zips/coding-components-sample-angular.zip
Binary file not shown.
Binary file modified zips/coding-components-sample-cdn.zip
Binary file not shown.
Binary file modified zips/coding-components-sample-react.zip
Binary file not shown.
Binary file modified zips/coding-components-sample-vite.zip
Binary file not shown.
Binary file modified zips/coding-components-sample-vue.zip
Binary file not shown.
Binary file modified zips/coding-components-sample-webpack.zip
Binary file not shown.
Binary file modified zips/core-sample-esbuild.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-angular-cli.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-custom-ui.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-custom-workers.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-deno.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-esm-cdn.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-node.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-oauth.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-react.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-vite-ts.zip
Binary file not shown.
Binary file modified zips/core-sample-jsapi-vue.zip
Binary file not shown.
Binary file modified zips/core-sample-rollup.zip
Binary file not shown.
Binary file modified zips/core-sample-webpack.zip
Binary file not shown.
Binary file modified zips/map-component-sample-angular.zip
Binary file not shown.
Binary file modified zips/map-component-sample-cdn.zip
Binary file not shown.
Binary file modified zips/map-component-sample-react.zip
Binary file not shown.
Binary file modified zips/map-component-sample-vite.zip
Binary file not shown.
Binary file modified zips/map-component-sample-vue.zip
Binary file not shown.
Binary file modified zips/map-component-sample-webpack.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 776435c

Please sign in to comment.