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

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

Merged
merged 2 commits into from Apr 27, 2024

Conversation

mac-alves
Copy link
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>

Copy link

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
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
Contributor Author

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

@guybedford guybedford merged commit a9e092a into systemjs:main Apr 27, 2024
2 checks passed
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.

None yet

2 participants