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

how to use "importmap-shim" with src attribute? #388

Open
jogibear9988 opened this issue Aug 13, 2023 · 2 comments
Open

how to use "importmap-shim" with src attribute? #388

jogibear9988 opened this issue Aug 13, 2023 · 2 comments

Comments

@jogibear9988
Copy link
Contributor

jogibear9988 commented Aug 13, 2023

I've the following code:

    <script>
      const importMap = {
        imports: {
          "jquery.fancytree/": "./node_modules/jquery.fancytree/",
          "monaco-editor/": "./node_modules/monaco-editor/",
          "@node-projects/web-component-designer": "./node_modules/@node-projects/web-component-designer/dist/index.js",
          "@node-projects/web-component-designer/": "./node_modules/@node-projects/web-component-designer/",
          "@adobe/css-tools": "./node_modules/@adobe/css-tools/dist/index.mjs",
          "dock-spawn-ts/": "./node_modules/dock-spawn-ts/",
          "@node-projects/base-custom-webcomponent/": "./node_modules/@node-projects/base-custom-webcomponent/",
          "@node-projects/base-custom-webcomponent": "./node_modules/@node-projects/base-custom-webcomponent/dist/index.js",
          "@node-projects/lean-he-esm/": "./node_modules/@node-projects/lean-he-esm/",
          "@iobroker/socket-client/": "./node_modules/@iobroker/socket-client/",
          "@iobroker/socket-client": "./node_modules/@iobroker/socket-client/dist/esm/index.js",
          "tslib": "./node_modules/tslib/tslib.es6.mjs",
        }
      };
      //@ts-ignore
      importShim.addImportMap(importMap);
    </script>

works perfectly, but when I extract the importmap like this:

         <script type="importmap-shim" src="./dist/frontend/importmaps/importmap-config.json"></script>

it will be loaded by the browser but not be used.

it will work, if I paste the json directly into the

     <script type="importmap-shim"> tag 
@guybedford
Copy link
Owner

When you use <script type="importmap-shim"> you must also use <script type="module-shim"> as this runs the project in "shim mode", not polyfill mode.

@jogibear9988
Copy link
Contributor Author

I did use this:

<script type="module">
  importShim('./dist/frontend/runtime/controls.js');
</script>

I'll try the other mode

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

No branches or pull requests

2 participants