Skip to content

feat: add support for reading the mapping of loaded imports#2484

Merged
guybedford merged 2 commits intosystemjs:mainfrom
mac-alves:feat/get-import-map
Apr 27, 2024
Merged

feat: add support for reading the mapping of loaded imports#2484
guybedford merged 2 commits intosystemjs:mainfrom
mac-alves:feat/get-import-map

Conversation

@mac-alves
Copy link
Copy Markdown
Contributor

Description

During the implementation of the library, I needed to read the values from the mapping without the need to call the import file again via fetch. Since I didn't see anything within the code that could provide these values, I'm sending this addition if possible.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf8" />
    <link rel="icon" href="data:," />
    <script type="systemjs-importmap" src="./import-map.json"></script>
  </head>
  <body>
    <script>
      const importMap = System.getImportMap();
    </script>
  </body>
</html>

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2024

File size impact

Merging feat/get-import-map into main will impact 3 files in 2 groups.

browser (2/2)
File raw gzip brotli Event
dist/s.min.js +64 (7,971) +15 (3,148) +17 (2,862) modified
dist/system.min.js +64 (12,320) +10 (4,754) +12 (4,284) modified
Total size impact +128 (20,291) +25 (7,902) +29 (7,146)
node (1/1)
File raw gzip brotli Event
dist/system-node.cjs +100 (522,049) +18 (126,154) -71 (84,880) modified
Total size impact +100 (522,049) +18 (126,154) -71 (84,880)
extras (0/8)

No impact on files in extras group.

Generated by file size impact during size-impact#8801662311

@guybedford
Copy link
Copy Markdown
Member

I wonder if we should do what es-module-shims does here and clone the data so it doesn't expose mutability - https://github.com/guybedford/es-module-shims/blob/main/src/es-module-shims.js#L126 ?

@mac-alves
Copy link
Copy Markdown
Contributor Author

Hi, @guybedford I agree, I added the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants