0

I have a question and I would love to get some help please :)

I installed a new vite project with React and TypeScript:

pnpm create vite some-app --template react-ts

When I run pnpm build the build takes approximately 800ms.

After installing @arcgis/core and although using dymanic-import

import { useEffect, useState } from "react";
import "./App.css";

const getAll = async () => {
  const { default: Basemap } = await import("@arcgis/core/Basemap.js");
  const { default: TileLayer } = await import("@arcgis/core/layers/TileLayer");
  const { default: VectorTileLayer } = await import(
    "@arcgis/core/layers/VectorTileLayer"
  );
  const { default: WebTileLayer } = await import(
    "@arcgis/core/layers/WebTileLayer"
  );
  const { default: arcGISMap } = await import("@arcgis/core/Map.js");
  const { default: MapView } = await import("@arcgis/core/views/MapView");
  const { default: BaseMapGallery } = await import(
    "@arcgis/core/widgets/BasemapGallery"
  );
  const { default: LocalBaseMapsSource } = await import(
    "@arcgis/core/widgets/BasemapGallery/support/LocalBasemapsSource"
  );
  const { default: Expand } = await import("@arcgis/core/widgets/Expand");
  return {
    Basemap,
    TileLayer,
    VectorTileLayer,
    WebTileLayer,
    arcGISMap,
    MapView,
    BaseMapGallery,
    LocalBaseMapsSource,
    Expand,
  };
};

function App() {
  useEffect(() => {
    (async () => {
      const x = await getAll();
      // draw a map on a div...
      console.log(x);
    })();
  }, []);

  return <>some new app that draws a map...</>;
}

export default App;

The build takes about 30 seconds.

new build time picture

Is there anyway to fix it? Is there anything I could do to reduce the build time?

1
  • 1
    ArcGIS is a large package. It will increase the build time for sure, and the more packages you add, the build time will keep increasing. You are already using dynamic imports, which is good. But it is helping you mainly to improve the initial load time of your app, not improving build time much. I think you should not be worried about build time much. Your app will be built only once in production. Commented Dec 15, 2024 at 23:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.