Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Maps #1108

Open
2 of 3 tasks
marklundin opened this issue Feb 29, 2024 · 2 comments
Open
2 of 3 tasks

Import Maps #1108

marklundin opened this issue Feb 29, 2024 · 2 comments
Assignees

Comments

@marklundin
Copy link
Member

marklundin commented Feb 29, 2024

First class support for Import Maps

As we move toward support for ESM Scripts playcanvas/engine#4767, users should be able define import maps in esm scripts such as..

{
  "imports": {
    "@utils": "/scripts/utils",
    "firebase": "https://esm.run/firebase"
  }
}

This will allow the to use module specifiers in their project, which helps to structure projects

import { initializeApp } from 'firebase/app';
import { lerp } from '@utils';

Ideally users can create a import-map.json in the root of the asset registry which is used by the editor when parsing scripts, in the launcher when running and also during bundling and exporting. This would allow import maps to be edited both by hand and by an editor panel for installing modules from NPM.

Tasks

@Maksims
Copy link

Maksims commented Feb 29, 2024

The import map for the Editor script should be generated automatically, and I don't think it should be exposed to users. This import map will contain records that follow the assets folder structure.
An additional option could be the ability to set the script import name on the asset itself, which will add another import map record during generation.

Custom import maps - could be used per project, just like the "External Scripts" feature in the settings. With similar UX.

So that way there is little possibility for a human mistake (by editing a JSON), and there is still flexibility to define custom import names and/or external imports.

@marklundin
Copy link
Member Author

Yeah there will likely be some UX around editing data, we may even have some UX for searching/installing through NPM

@marklundin marklundin moved this from Todo to In progress in ESM Scripts Mar 4, 2024
@marklundin marklundin moved this from In progress to Todo in ESM Scripts Mar 5, 2024
@marklundin marklundin moved this from Todo to In progress in ESM Scripts May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

2 participants