Skip to content

Commit

Permalink
Merge pull request #407 from Esri/rslibed/assets
Browse files Browse the repository at this point in the history
Update assetsPath logic
  • Loading branch information
rslibed committed Sep 10, 2024
2 parents eff064e + b5b8c0d commit 6150ec6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions packages/instant-apps-components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.0.0-beta.253

### General

- Update locale util to use `getAssetPath`

## v1.0.0-beta.252

### instant-apps-language-translator-item
Expand Down
4 changes: 2 additions & 2 deletions packages/instant-apps-components/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/instant-apps-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"homepage": "https://esri.github.io/instant-apps-components",
"name": "@esri/instant-apps-components",
"version": "1.0.0-beta.252",
"version": "1.0.0-beta.253",
"description": "Reusable ArcGIS Instant Apps web components.",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/instant-apps-components/src/utils/locale.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// https://medium.com/stencil-tricks/implementing-internationalisation-i18n-with-stencil-5e6559554117
import { getAssetPath } from '@stencil/core';
import { loadModules } from '../utils/loadModules';
import { languageMap } from './languageUtil';

Expand Down Expand Up @@ -28,7 +29,6 @@ interface StringBundle {

async function fetchLocaleStringsForComponent<T extends StringBundle = StringBundle>(componentName: string, locale: string): Promise<T> {
const localePath = `assets/t9n/${componentName}/resources_${locale}.json`;
const primaryURL = new URL(`./${localePath}`, window.location.href).href;
const fallbackURL = `${getFallbackUrl()}/dist/${localePath}`;

async function fetchJson(url: string): Promise<T> {
Expand All @@ -45,7 +45,7 @@ async function fetchLocaleStringsForComponent<T extends StringBundle = StringBun
}

try {
return await fetchJson(IS_TEST_ENV ? fallbackURL : primaryURL);
return await fetchJson(IS_TEST_ENV ? fallbackURL : getAssetPath(localePath));
} catch (primaryError) {
console.error(`Primary fetch error: ${primaryError}`); // Log primary fetch error with more context
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/instant-apps-components/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const config: Config = {
{ type: 'dist-custom-elements', customElementsExportBehavior: 'auto-define-custom-elements' },
{
type: 'www',
copy: [{ src: '**/*.html' }, { ...t9nAssetsObj, dest: 'assets/t9n' }],
copy: [{ src: '**/*.html' }, { ...t9nAssetsObj, dest: 'assets/t9n' }, { src: 'assets', dest: 'build/assets' }],
serviceWorker: null, // disable service workers
},
reactOutputTarget({
Expand Down

0 comments on commit 6150ec6

Please sign in to comment.