Esri / calcite-design-system

A monorepo containing the packages for Esri's Calcite Design System
https://developers.arcgis.com/calcite-design-system/
Other
270 stars 74 forks source link

Update calciteConfig message when same or different versions #9721

Open odoe opened 1 week ago

odoe commented 1 week ago

Check existing issues

Description

Currently, when the globalThis.calciteConfig is checked if a Calcite version is loaded, it emits a message that doesn't distinguish if the same version or a different version was loaded.

There are cases when the same version could be loaded if an app that uses Stencil built components mixes import of components and defineCustomElements, which is probably not best practice.

Not sure what the message when the same version is loaded should be, but definitely a distinct warning when a different version is loaded, probably means something went wrong.

Acceptance Criteria

Relevant Info

No response

Which Component

calcite-components/src/utils/config.ts

Example Use Case

No response

Priority impact

impact - p3 - not time sensitive

Calcite package

Esri team

ArcGIS Maps SDK for JavaScript

jcfranco commented 6 days ago

Confirm regular Vite setup doesn't add the same message with our example

@odoe I can't reproduce the same-version warning with the vite example. Do you have any suggestions on how to get the warning?

odoe commented 6 days ago

@jcfranco I made a repro here https://github.com/odoe/calcite-dupe-issue

It updates the main.js to do both defineCustomElements and an import from map components. This will trigger the loading of the config file from two different dist folders in calcite.

import './style.css';
// loads calcite from components folder
import { defineCustomElements as defineCalciteElements } from "@esri/calcite-components/dist/loader";
// loads calcite from esm folder
import "@arcgis/map-components/dist/components/arcgis-map";

defineCalciteElements(window, {
  resourcesUrl: "https://js.arcgis.com/calcite-components/2.10.1/assets",
});

const loader = document.createElement('calcite-loader');
document.body.appendChild(loader);