Skip to content

Commit

Permalink
feat(importmap): add @juno scope if unscoped
Browse files Browse the repository at this point in the history
importmap and widgetLoader: add @juno scope if package is unscoped.
This is the case for sapcc/juno packages
  • Loading branch information
andypf committed Jun 26, 2024
1 parent e0a49de commit 24940eb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/assets-overview/src/components/details/TabPreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const TabPreview = ({ asset }) => {
if (!asset || !appProps) return

return {
name: asset?.name?.replace(/^#/, ""), // replace leading # from name
name: asset?.name,
version: asset?.version,
appPreview: asset?.latestAppPreview,
props: appProps,
Expand Down
2 changes: 1 addition & 1 deletion apps/widget-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "widget-loader",
"version": "1.3.3",
"version": "1.3.4",
"author": "UI-Team",
"contributors": [
"Andreas Pfau"
Expand Down
3 changes: 2 additions & 1 deletion apps/widget-loader/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ const ESM_SHIM_URL = "/externals/[email protected]/dist/es-module-shims.js"
// else the version is not changed
}

const importmapAppName = name?.startsWith("@") ? name : `@juno/${name}`
// get the app URL
// from given url or from importmap based on name and version
let appURL = url || importmap.imports[`@juno/${name}@${version}`]
let appURL = url || importmap.imports[`${name}@${version}`]

// get app props from the data-props-* arguments
let appProps = { currentHost: new URL(appURL).href }
Expand Down
6 changes: 3 additions & 3 deletions ci/scripts/esm_build/generate_importmap.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ for (let name in packageRegistry) {
// since package regisrty contains only juno packages,
// we need to add this package to the importmap's imports section under the
// @juno scope
// remove leading @ from pkg.name if first char is @
const pkgName = pkg.name.startsWith("@") ? pkg.name.slice(1) : pkg.name
// add @juno for packages that are not scoped
const pkgName = pkg.name.startsWith("@") ? pkg.name : `@juno/${pkg.name}`

importMap.imports[
`@juno/${pkgName}@${pkg.version}`
`${pkgName}@${pkg.version}`
] = `${options.baseUrl}/${pkg.path}/${pkg.entryFile}`

// if the package has no peer dependencies, we can skip further processing
Expand Down

0 comments on commit 24940eb

Please sign in to comment.