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
1 change: 1 addition & 0 deletions packages/components/addon-main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const flightIconSprite = require('@hashicorp/flight-icons/svg-sprite/svg-sprite-

module.exports = {
...addonV1Shim(__dirname),

contentFor(type, config) {
if (
!config.flightIconsSpriteLazyEmbed &&
Expand Down
1 change: 0 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"ember-concurrency": "^4.0.4",
"ember-element-helper": "^0.8.6",
"ember-focus-trap": "^1.1.1",
"ember-get-config": "^2.1.1",
"ember-modifier": "^4.2.2",
"ember-power-select": "^8.7.1",
"ember-stargate": "^1.0.2",
Expand Down
20 changes: 14 additions & 6 deletions packages/components/src/instance-initializers/load-sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
* SPDX-License-Identifier: MPL-2.0
*/

import config from 'ember-get-config';
import { isTesting } from '@embroider/macros';

export async function initialize() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (config?.flightIconsSpriteLazyEmbed) {
import type ApplicationInstance from '@ember/application/instance';

interface Config {
flightIconsSpriteLazyEmbed?: boolean;
}

export async function initialize(appInstance: ApplicationInstance) {
const config = appInstance.resolveRegistration(
'config:environment'
) as Config;

if (config.flightIconsSpriteLazyEmbed) {
const { default: svgSprite } = await import(
'@hashicorp/flight-icons/svg-sprite/svg-sprite-module'
);

// in test environments we can inject the sprite directly into the ember testing container
// to avoid issues with tools like Percy that only consider content inside that element
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (config.environment === 'test') {
if (isTesting()) {
const container = window.document?.getElementById('ember-testing');

if (container && !container.querySelector('.flight-sprite-container')) {
Expand Down
5 changes: 2 additions & 3 deletions packages/components/src/modifiers/hds-code-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Modifier from 'ember-modifier';
import { assert, warn } from '@ember/debug';
import { registerDestructor } from '@ember/destroyable';
import { task } from 'ember-concurrency';
import config from 'ember-get-config';
import { macroCondition, isTesting } from '@embroider/macros';
import { Compartment } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { guidFor } from '@ember/object/internals';
Expand Down Expand Up @@ -208,8 +208,7 @@ export default class HdsCodeEditorModifier extends Modifier<HdsCodeEditorSignatu
// if the editor does not exist, setup the editor
else {
// the intersection observer makes loading unreliable in tests
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (config.environment === 'test') {
if (macroCondition(isTesting())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain a bit how this works?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that part essentially would remove this code at build time if environment is anything but test this pattern should be used when there is no way to get config from the host app or you want to be removing part of code at the build time

// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._setupTask.perform(element, positional, named);
} else {
Expand Down
28 changes: 3 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"ember-template-lint": "^7.7.0",
"ember-truth-helpers": "^4.0.3",
"ember-try": "^4.0.0",
"ember-unique-id-helper-polyfill": "^1.2.2",
"eslint": "^9.27.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-ember": "^12.5.0",
Expand Down
3 changes: 2 additions & 1 deletion website/app/routes/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Route from '@ember/routing/route';
import fetch from 'fetch';
import config from 'ember-get-config';

import config from 'website/config/environment';

export default class ApplicationRoute extends Route {
model() {
Expand Down
3 changes: 2 additions & 1 deletion website/app/routes/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
isUnauthorizedResponse,
isNotFoundResponse,
} from 'ember-fetch/errors';
import config from 'ember-get-config';
import { service } from '@ember/service';
import { action } from '@ember/object';
import { reject } from 'rsvp';

import config from 'website/config/environment';

export default class ShowRoute extends Route {
@service router;
queryParams = {
Expand Down
3 changes: 2 additions & 1 deletion website/app/services/head-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
*/

import HeadDataService from 'ember-meta/services/head-data';
import config from 'ember-get-config';
import { service } from '@ember/service';

import config from 'website/config/environment';

export default class CustomHeadDataService extends HeadDataService {
@service router;

Expand Down
1 change: 0 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
"ember-cli-terser": "^4.0.2",
"ember-concurrency": "^4.0.4",
"ember-fetch": "^8.1.2",
"ember-get-config": "^2.1.1",
"ember-load-initializers": "^3.0.1",
"ember-math-helpers": "^4.2.1",
"ember-meta": "^2.0.0",
Expand Down
Loading