Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/calcite-components/src/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { makeRuntime } from "@arcgis/lumina";
import globalScript from "./utils/globalScript";

globalScript();
import "./utils/globalScript";

export const runtime = makeRuntime();

Expand Down
24 changes: 11 additions & 13 deletions packages/calcite-components/src/utils/globalScript.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
/**
* This file is imported in src/runtime.ts
*/
import { isServer } from "lit";
import { initModeChangeEvent } from "./mode";
import { stampVersion } from "./config";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it a bit curious that stampVersion will not log the 2nd time if multiple calcite versions are present - dual-bundling can lead to weird errors happening, so it is good to make developer aware of it early.

but, I was able to abuse the fact that sampVersion won't wire the 2nd time by adding (globalThis as { calciteConfig?: { version?: string } }).calciteConfig ??= { version: " " }; to silence this message in Lumina dev server
(since Lumina controls importing calcite, detecting dual bundling is less important)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation. It used to warn when handling a previously stamped version, but it was causing confusion (see #9721 (comment) and #9739).


/**
* This file is imported in Stencil's `globalScript` config option.
*
* @see [Stencil's globalScript](https://stenciljs.com/docs/config#globalscript).
*/
export default function (): void {
if (!isServer) {
if (document.readyState === "interactive") {
initModeChangeEvent();
} else {
document.addEventListener("DOMContentLoaded", () => initModeChangeEvent(), { once: true });
}
if (!isServer) {
if (document.readyState === "interactive") {
initModeChangeEvent();
} else {
document.addEventListener("DOMContentLoaded", initModeChangeEvent, { once: true });
}
}

stampVersion();
if (process.env.NODE_ENV !== "test") {
queueMicrotask(stampVersion);
}
Loading