{"_id":"@uupaa/dynamic-import-polyfill","_rev":"1-0e1a9f8eb7efce7d5e354fa3d6bb0c36","name":"@uupaa/dynamic-import-polyfill","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.2":{"name":"@uupaa/dynamic-import-polyfill","version":"1.0.2","description":"importModule() is a polyfill of import().","repository":{"type":"git","url":"git+https://github.com/uupaa/dynamic-import-polyfill.git"},"scripts":{},"publishConfig":{"access":"public"},"author":{"name":"uupaa.js@gmail.com"},"license":"MIT","main":"importModule.js","keywords":["dynamic","import","polyfill","module","ESModule","ESModules","uupaa"],"gitHead":"eb66ad8bc6d0bb1734f080ceadec938766486c41","bugs":{"url":"https://github.com/uupaa/dynamic-import-polyfill/issues"},"homepage":"https://github.com/uupaa/dynamic-import-polyfill#readme","_id":"@uupaa/dynamic-import-polyfill@1.0.2","_nodeVersion":"11.7.0","_npmVersion":"6.7.0","dist":{"integrity":"sha512-V3vzdXunOKKob1F+2ldv/4iGQoQA/iyqtW8PVlr1v16xCCKL831pGUubT+vs5/9wxTE/zBKEhjIjmmpK6nqw2A==","shasum":"e540cfd8671058fe1e48f816fc8be07e058d5d3a","tarball":"https://registry.npmjs.org/@uupaa/dynamic-import-polyfill/-/dynamic-import-polyfill-1.0.2.tgz","fileCount":18,"unpackedSize":15137,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdSukUCRA9TVsSAnZWagAANrEP/1qonVuNPUHfPVLaQIxf\nZxeNMdARCgkR4AX23qNXiGe36dvqCo4QYtsuQcDdkoRKvh2lh0zK7ZAA3kRn\nqizuA/JTmqiZvo/woXHqo5SSyyMT1YapWOYx97hDvHUQut0cAMoWp/BTjb1P\nd3KR/uYJZaSsqB6mRyOykiN3NcNxpHFZEiXPOPcqqB/c0wn1Fo7b66oP0nSt\nzQK7uFCrKBLz/sh6qCzINn7FP1LqKeRvj/Q5y1f4vR8GeBSfgW8/c1iosIuM\n1j7G6w3wZntODa+GcUeHZXAvwwleFWvMwJ54Kxf7IUMUfC0uf14/k/MAA79j\nrYk4mzoZa8vQihDcINCwy/lm+Xh6Jzzo3HRKauRpvHo2qD61+Da3zKXyG+zu\ngJ4FMLN093E2OuDD+01hNummCNdRspyqGuSRkcqnzemaC0jHF64ML47tlW50\n09ZPZJVhY0PojGsXnb3IBDL8Hw9t3w/UdkQucBE0UfOg6Rs9/Ekd8O/V3zS7\nHxWWOd6ypXvHo0eTQVGx2G5+huKi7XZUHl5j1fWXFQNnYd9RSIPO+vVlldY2\nKKztlNKuXB30kyG5VYf3i6HBD4HUyy8kXUQ+h+UDGyZgYGiDh6IMyth/iUrh\nyiQ5Vn//nd09gc5ndc/FPtY4G9kOrpOBaWRfK/g5K8EBx6BH67odmtTPRf8j\nBMsS\r\n=qZe3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH4egbppQAPL9l9dL9pHC4oGUERUHvNRo/fAuTaBMnpjAiEA+qVjMdCYGnRR5Bbxk4DougZ50qmfgJivIwr8GqjpeGM="}]},"maintainers":[{"name":"uupaa","email":"uupaa.js@gmail.com"}],"_npmUser":{"name":"uupaa","email":"uupaa.js@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dynamic-import-polyfill_1.0.2_1565190420138_0.5164025641934131"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-07T15:06:59.932Z","1.0.2":"2019-08-07T15:07:00.258Z","modified":"2022-04-07T10:02:48.993Z"},"maintainers":[{"name":"uupaa","email":"uupaa.js@gmail.com"}],"description":"importModule() is a polyfill of import().","homepage":"https://github.com/uupaa/dynamic-import-polyfill#readme","keywords":["dynamic","import","polyfill","module","ESModule","ESModules","uupaa"],"repository":{"type":"git","url":"git+https://github.com/uupaa/dynamic-import-polyfill.git"},"author":{"name":"uupaa.js@gmail.com"},"bugs":{"url":"https://github.com/uupaa/dynamic-import-polyfill/issues"},"license":"MIT","readme":"# Dynamic import() polyfill\n\nimportModule() is a polyfill of dynamic import JavaScript function.\n\n## Prepare\n\n`npm i -S @uupaa/dynamic-import-polyfill`\n\n## Browser support\n\n| Browser                   | `<script type=\"module\">` | `import()`<br>(js native) | `importModule()`<br>(polyfill) |\n|---------------------------|------------|---------|------------------------------|\n| Chrome                    | 61+        | 63+     | 61+                          |\n| Chrome (Android)          | 61+        | 63+     | 61+                          |\n| Safari                    | 10.1+      | 11+     | 10.1+                        |\n| Safari (iOS)              | 10.3+      | 11+     | 10.3+                        |\n| Firefox                   | 60+        | 67+     | 60+                          |\n| Edge                      | 16+        | :x:     | 16+                          |\n| new Edge (Chromium based) | 76+        | 76+     | 76+                          |\n| IE                        | :x:        | :x:     | :x:                          |\n\nBrowser should supports are ES Modules(`<script type=\"module\">`), Promise, Blob and window.URL functions.\n\n`import()` function browser compatibilitiy resources:\n\n- MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Browser_compatibility\n- Can I use: https://caniuse.com/#search=import\n\n## Usage\n\nasync / await style\n\n```js\n<script type=\"module\">\nimport { importModule } from \"https://uupaa.github.io/dynamic-import-polyfill/importModule.js\";\n\n(async() => {\n  const Modules = {\n    Lib1: \"./Lib1.js\",\n    Lib2: \"https://example.com/Lib2.js\",\n  };\n  const { Lib1 } = await importModule(Modules.Lib1); // named export and import\n  const { default: Lib2 } = await importModule(Modules.Lib2); // default export and import\n\n  const lib1 = new Lib1();\n  const lib2 = new Lib2();\n  console.log( lib1.say() );\n  console.log( lib2.say() );\n})();\n```\n\nor Promise style.\n\n```js\n<script type=\"module\">\nimport { importModule } from \"https://uupaa.github.io/dynamic-import-polyfill/importModule.js\";\n\nimportModule(\"./Lib1.js\").then(Lib1 => {\n  const lib1 = new Lib1();\n  console.log( lib1.say() );\n});\n```\n\n\n## Demo\n\n- [use native import() or polyfill importModule()](https://uupaa.github.io/dynamic-import-polyfill/test/index.html)\n- [use native import()](https://uupaa.github.io/dynamic-import-polyfill/test/native.html)\n- [use polyfill importModule(abs-url)](https://uupaa.github.io/dynamic-import-polyfill/test/polyfill.abs.html)\n- [use polyfill importModule(rel-url)](https://uupaa.github.io/dynamic-import-polyfill/test/polyfill.rel.html)\n\n```html\n<!DOCTYPE html><html>\n<head>\n<meta charset=\"utf-8\"><title>dynamic-import-polyfill</title>\n</head>\n<body>\n  <script type=\"module\">\n    import { importModule } from \"../importModule.js\";\n\n    (async() => {\n      const Modules = {\n        a: \"https://uupaa.github.io/dynamic-import-polyfill/test/a.js\",\n        b: \"https://uupaa.github.io/dynamic-import-polyfill/test/b.js\",\n        c: \"https://uupaa.github.io/dynamic-import-polyfill/test/c.js\",\n      };\n\n      const usePolyfill = Date.now() % 2;\n\n      if (usePolyfill) {\n        console.log(\"use polyfill\");\n        const { a } = await importModule(Modules.a);\n        const { default: b } = await importModule(Modules.b);\n        const { c } = await importModule(Modules.c);\n        console.log( a(), b(), c() );\n      } else {\n        console.log(\"use native\");\n        // use native\n        const { a } = await import(Modules.a);\n        const { default: b } = await import(Modules.b);\n        const { c } = await import(Modules.c);\n        console.log( a(), b(), c() );\n      }\n    })();\n  </script>\n</body>\n</html>\n```\n\n","readmeFilename":"README.md"}