Skip to content

Relative @view URLs fail — import() resolves against bundle URL, not page URL #6

Description

@melvincarvalho

Bug

When @view in JSON-LD uses a relative path (e.g. ./src/panes/task.js), the dynamic import() resolves it against the mashlib bundle's own URL (the CDN) rather than the page's location.href. This means only absolute URLs work for @view.

Where

src/index.ts ~line 120 in renderView():

const paneModule = await import(/* webpackIgnore: true */ jsonld['@view'])

Expected

@view: "./src/panes/task.js" on a page at http://localhost:3003/index.html should load http://localhost:3003/src/panes/task.js.

Actual

The import() resolves the relative path against the bundle URL (e.g. https://unpkg.com/solid-shim/dist/mashlib.min.js), resulting in a 404.

Fix

Resolve relative URLs against the page before importing:

const viewUrl = new URL(jsonld['@view'], window.location.href).href
const paneModule = await import(/* webpackIgnore: true */ viewUrl)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions