{"_id":"dimport","_rev":"1516360","name":"dimport","description":"Run ES Module syntax in any browser – even IE!","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"time":{"modified":"2021-11-10T06:21:44.000Z","created":"2019-04-03T00:40:18.579Z","1.0.0":"2019-04-11T08:18:27.866Z","0.1.5":"2019-04-10T19:10:39.985Z","0.1.4":"2019-04-10T18:07:38.857Z","0.1.3":"2019-04-10T01:11:18.782Z","0.1.2":"2019-04-10T00:37:58.955Z","0.1.1":"2019-04-05T18:28:32.663Z","0.1.0":"2019-04-05T18:19:10.511Z","0.0.0":"2019-04-03T00:40:18.579Z"},"users":{},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"versions":{"1.0.0":{"name":"dimport","version":"1.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"description":"Run ES Module syntax in any browser – even IE!","unpkg":"dist/index.min.js","umd:main":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"scripts":{"build":"rm -rf nomodule legacy dist && node bin","test":"eslint src bin"},"dependencies":{"rewrite-imports":"^2.0.3"},"devDependencies":{"eslint":"^5.16.0","microbundle":"^0.11.0"},"keywords":["esm","dynamic","dynamic-import","polyfill","imports","import","module"],"gitHead":"ad364ebb37302c586a62ef00bce95f2feb759286","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"homepage":"https://github.com/lukeed/dimport#readme","_id":"dimport@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"d5c09564f621e7b24b2e333cccdf9b2303011644","size":6393,"noattachment":false,"key":"/dimport/-/dimport-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dimport/download/dimport-1.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dimport_1.0.0_1554970707741_0.8545340709217226"},"_hasShrinkwrap":false,"publish_time":1554970707866,"_cnpm_publish_time":1554970707866},"0.1.5":{"name":"dimport","version":"0.1.5","repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"description":"WIP","unpkg":"dist/index.min.js","umd:main":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"scripts":{"build":"rm -rf nomodule legacy dist && node bin","test":"eslint src bin"},"dependencies":{"rewrite-imports":"^2.0.3"},"devDependencies":{"eslint":"^5.16.0","microbundle":"^0.11.0"},"keywords":["esm","dynamic","dynamic-import","imports","import","module"],"gitHead":"66fc493c55f5ecbf084bd9cf858686517103ee9a","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"homepage":"https://github.com/lukeed/dimport#readme","_id":"dimport@0.1.5","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"897cdec4fcbdf045f2191d1b68a73eb9873ad9b6","size":4742,"noattachment":false,"key":"/dimport/-/dimport-0.1.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/dimport/download/dimport-0.1.5.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dimport_0.1.5_1554923439874_0.19094974013710608"},"_hasShrinkwrap":false,"publish_time":1554923439985,"_cnpm_publish_time":1554923439985},"0.1.4":{"name":"dimport","version":"0.1.4","repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"description":"WIP","unpkg":"dist/index.min.js","umd:main":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"scripts":{"build":"rm -rf nomodule legacy dist && node bin","test":"eslint src bin"},"dependencies":{"rewrite-imports":"^2.0.3"},"devDependencies":{"bundt":"^0.4.0","eslint":"^5.16.0"},"keywords":["esm","dynamic","dynamic-import","imports","import","module"],"gitHead":"393d3e8e59ef36488917316b8010e60d33930ffc","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"homepage":"https://github.com/lukeed/dimport#readme","_id":"dimport@0.1.4","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"8f759e3509c7f9e4f30f50dfaeb73465d1895d49","size":4858,"noattachment":false,"key":"/dimport/-/dimport-0.1.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/dimport/download/dimport-0.1.4.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dimport_0.1.4_1554919658742_0.45794889123804317"},"_hasShrinkwrap":false,"publish_time":1554919658857,"_cnpm_publish_time":1554919658857},"0.1.3":{"name":"dimport","version":"0.1.3","repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"description":"WIP","unpkg":"dist/index.min.js","umd:main":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"scripts":{"build":"rm -rf nomodule legacy dist && node bin","test":"eslint src bin"},"dependencies":{"rewrite-imports":"^2.0.3"},"devDependencies":{"bundt":"^0.4.0","eslint":"^5.16.0"},"keywords":["esm","dynamic","dynamic-import","imports","import","module"],"gitHead":"0a1f935250cc75b4e78a3ca0548423bf69a3a5b8","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"homepage":"https://github.com/lukeed/dimport#readme","_id":"dimport@0.1.3","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"dd237ba7e457e89dda361510c7c1358f2f3af596","size":4851,"noattachment":false,"key":"/dimport/-/dimport-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/dimport/download/dimport-0.1.3.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dimport_0.1.3_1554858678620_0.7877172525773528"},"_hasShrinkwrap":false,"publish_time":1554858678782,"_cnpm_publish_time":1554858678782},"0.1.2":{"name":"dimport","version":"0.1.2","repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"description":"WIP","unpkg":"dist/index.min.js","umd:main":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"scripts":{"build":"rm -rf nomodule legacy dist && node bin","test":"eslint src bin"},"dependencies":{"rewrite-imports":"^2.0.3"},"devDependencies":{"bundt":"^0.4.0","eslint":"^5.16.0"},"keywords":["esm","dynamic","dynamic-import","imports","import","module"],"gitHead":"09017dfdae2b5f91ee6c3e44754305c3d92e0a8c","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"homepage":"https://github.com/lukeed/dimport#readme","_id":"dimport@0.1.2","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"dc2257caabb2e00c1f128de211478566b696a073","size":4854,"noattachment":false,"key":"/dimport/-/dimport-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/dimport/download/dimport-0.1.2.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dimport_0.1.2_1554856678778_0.7435191207748895"},"_hasShrinkwrap":false,"publish_time":1554856678955,"_cnpm_publish_time":1554856678955},"0.1.1":{"name":"dimport","version":"0.1.1","repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"description":"WIP","unpkg":"dist/index.min.js","umd:main":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"scripts":{"pretest":"npm run build","prebuild":"rm -rf nomodule dist","postbuild":"mv nomodule/index.min.js nomodule/index.js","build":"npm run -s build:nomodule && npm run -s build:module","build:module":"microbundle src/index.js --name dimport --no-sourcemap","build:nomodule":"microbundle src/nomodule.js --name dimport --no-sourcemap && mv dist nomodule","test":"tape test/*.js | tap-spec"},"dependencies":{"rewrite-imports":"^2.0.3"},"devDependencies":{"microbundle":"^0.4.3","tap-spec":"^4.1.2","tape":"^4.8.0"},"keywords":["esm","dynamic","dynamic-import","imports","import","module"],"gitHead":"6b0d66e4366445b1ea489b4df842a54ca4d92c97","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"homepage":"https://github.com/lukeed/dimport#readme","_id":"dimport@0.1.1","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"0b84f040d4d66106d61c6094fdd0cfe1fe1ba40f","size":4100,"noattachment":false,"key":"/dimport/-/dimport-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/dimport/download/dimport-0.1.1.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dimport_0.1.1_1554488912497_0.08250534408543109"},"_hasShrinkwrap":false,"publish_time":1554488912663,"_cnpm_publish_time":1554488912663},"0.1.0":{"name":"dimport","version":"0.1.0","repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"description":"WIP","umd:main":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"scripts":{"pretest":"npm run build","prebuild":"rm -rf nomodule dist","build":"npm run -s build:nomodule && npm run -s build:module","build:module":"microbundle src/index.js --name dimport --no-sourcemap","build:nomodule":"microbundle src/nomodule.js --name dimport --no-sourcemap && mv dist nomodule","test":"tape test/*.js | tap-spec"},"dependencies":{"rewrite-imports":"^2.0.3"},"devDependencies":{"microbundle":"^0.4.3","tap-spec":"^4.1.2","tape":"^4.8.0"},"keywords":["esm","dynamic","dynamic-import","imports","import","module"],"gitHead":"5b710a16bd6adfd539fdd335e45e0e40d31e6ac6","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"homepage":"https://github.com/lukeed/dimport#readme","_id":"dimport@0.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"45bb78318499288ed8ede5f76be80982d55f5e35","size":4131,"noattachment":false,"key":"/dimport/-/dimport-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dimport/download/dimport-0.1.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dimport_0.1.0_1554488350249_0.9548244534914698"},"_hasShrinkwrap":false,"publish_time":1554488350511,"_cnpm_publish_time":1554488350511},"0.0.0":{"name":"dimport","version":"0.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/dimport.git"},"description":"WIP","module":"dist/dimport.mjs","unpkg":"dist/dimport.min.js","main":"dist/dimport.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=6"},"scripts":{"build":"bundt","test":"tape test/*.js | tap-spec"},"keywords":[],"devDependencies":{"bundt":"^0.3.0","tap-spec":"^5.0.0","tape":"^4.10.1"},"gitHead":"485376b4d7acde2eaae91be9406dfbc2a08567e7","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"homepage":"https://github.com/lukeed/dimport#readme","_id":"dimport@0.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"4e6df3eaec1b347e97edb3fc25f26077a53c2ffd","size":1827,"noattachment":false,"key":"/dimport/-/dimport-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/dimport/download/dimport-0.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dimport_0.0.0_1554252018439_0.35903809243119045"},"_hasShrinkwrap":false,"publish_time":1554252018579,"_cnpm_publish_time":1554252018579}},"readme":"# dimport [![Build Status](https://badgen.now.sh/travis/lukeed/dimport)](https://travis-ci.org/lukeed/dimport)\n\n> Run ES Module syntax (`import`, `import()`, and `export`) in any browser &mdash; even IE!\n\nAt its core, `dimport` is a polyfill for ES Module syntax, including [dynamic imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports)!<br>\nAnd with it, you can serve modern ESM-driven application files to any browser.\n\nWhile browsers _are_ increasing support for JavaScript modules natively, the current landscape is not easy to navigate.<br>\nFor example, many browsers _do support_ ESM syntax (aka, `import` and `export`) within `<script type=module />` tags; however, not all of these support _dynamic import_ statements since it came later.\nIn order to leverage the benefits of ESM today, a developer must choose between:\n\n* dropping support for lagging browsers\n* complicating their development process\n* building and/or distributing multiple versions of their application\n* abstaining from shipping ESM syntax at all :cry:\n\nNow, `dimport` allows the developer to ship ESM **today** to all browsers without comproimse.<br>\nBetter yet, the development and distribution processes are simplified, if not unchanged.\n\nPS: Check out the [`/examples`](/examples) directory~!\n\n<br>\n\n---\n\n***Important***\n\nThis module **does not** convert your ES2015+ syntax into ES5 or below!<br>\nWhile `dimport` may allow older browsers to parse and interpret the ESM format, it does nothing to make the _contents_ of your file(s) backwards compatible.\n\n---\n\n<br>\n\n## Modes\n\nThere are three \"versions\" of `dimport`, each of which utilize different APIs and approaches to yield full ESM compatability.\n\nPlease note that **all modes** check for native `import()` support first and foremost.<br>\nThis means that `dimport` won't do anything if it doesn't have to.\n\n#### \"module\"\n> **Size (gzip):** 675 bytes<br>\n> **Availablility:** [UMD](https://unpkg.com/dimport), [CommonJS](https://unpkg.com/dimport/dist/index.js), [ES Module](https://unpkg.com/dimport?module)<br>\n> **Requires:** `script[type=module]`, `fetch`, `Promise`, `URL`\n\nSince _static_ `import` statements are supported, this mode parses all _dynamic_ `import()`s and creates temporary `script[type=module]` tags pointing to the resource's full, canonical URL. Once the temporary script loads, the originating Promise is resolved, returning the contents.\n\n#### \"nomodule\"\n> **Size (gzip):** 918 bytes<br>\n> **Availablility:** [UMD](https://unpkg.com/dimport/nomodule), [ES Module](https://unpkg.com/dimport/nomodule/index.mjs)<br>\n> **Requires:** `fetch`, `Promise`, `URL`\n\nAll `import`, `export`, and `import()` statements are dynamically rewritten to CommonJS modules so that their contents/exports are easily returned.\n\nAny `import` statements are parsed early, ensuring full canonical URLs, and then the whole file is wrapped in a `Promise.all` chain, guaranteeing each `import` its desired module.\n\n#### \"legacy\"\n> **Size (gzip):** 1143 bytes<br>\n> **Availablility:** [UMD](https://unpkg.com/dimport/legacy), [ES Module](https://unpkg.com/dimport/legacy/index.mjs)<br>\n> **Requires:** `Promise`, `XMLHttpRequest`\n\nTakes the same approach as [\"nomodule\"](#nomodule), but inserts alternatives to `fetch` and `URL`.\n\n> **Important:** You will need to supply your own Promise polyfill for IE support.\n\n\n## Usage\n\n> Don't miss the [`/examples`](/examples) directory :sparkles:\n\nIt's possible to use `dimport` in a variety of ways!\n\nThe simplest way is to connect a few `<script/>` tags to [unpkg.com](https://unpkg.com/):\n\n```html\n<!-- Load the \"module\" version on browsers that can support it. -->\n<script type=\"module\" src=\"https://unpkg.com/dimport?module\" data-main=\"/bundle.js\"></script>\n\n<!-- Load the \"nomodule\" version on older browsers – acts as fallback! -->\n<script type=\"nomodule\" src=\"https://unpkg.com/dimport/nomodule\" data-main=\"/bundle.js\"></script>\n```\n\nIn the sample above, a browser will automatically choose which script `type` to parse.<br>\nThis means the two scripts can live side-by-side without loading your application twice!<br>\nFinally, the _same_ application file (`bundle.js`) can be used, despite the `module`-vs-`nomodule` choice.\n\nYou will also notice that the scripts have a `data-main=\"\"` attribute.<br>\nThis the path to _your application_ or _your ESM-containing file_ you wish to load.\n\nOnce `dimport` has loaded, it circles back and see that its `<script/>` caller also wants it to load a file.<br>\nAlternatively, `dimport` can load an inline script from its caller!\n\n```html\n<!-- We can use any \"mode\" here, but choosing only 1 for simplicity -->\n<script src=\"https://unpkg.com/dimport/nomodule\">\n  // Notice that we can use `import` inside a script without \"type=module\"\n  import { h, render } from 'https://unpkg.com/preact?module';\n\n  render(\n    h('h1', null, 'Hello world'),\n    document.body\n  );\n</script>\n```\n\nFinally, `dimport` is available for programmatic use and/or usable _within_ your bundle (via Webpack or Rollup)\n\n```\n$ npm install --save dimport\n```\n\n```js\nimport dimport from 'dimport';\n// or, without bundling\nimport dimport from 'https://unpkg.com/dimport?module';\n\n// Pass in URLs or file paths\n// ~> like `import()` usage\ndimport('./foo.js').then(...);\n```\n\n\n## API – Programmatic\n\n### dimport(url)\n\nReturns: `Promise`\n\nReturns a Promise containing the module.\n\n<!-- > **Note:** The Promise-requestor is cached for instant reuse. -->\n\n#### url\nType: `String`\n\nThe URL of the script to import.\n\n> **Note:** Will be transformed into a full URL if not already – see [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL#Examples)\n\n\n## Browser Support\n\nThe `dimport` columns yield support for **both** static and dynamic imports.\n\n> **Important:** Chart represents ESM syntax only!<br>Not indicative of ES2015+ syntax usage within your app.\n\n| Browser | `import`<br>native | `import()`<br>native | dimport<br>module | dimport<br>nomodule | dimport<br>legacy |\n|---------|--------------------|----------------------|-------------------|---------------------|-------------------|\n| Chrome  | 61                 | 63                   | 61                | 42                  | :+1:<sup>*</sup>  |\n| Safari  | 10.1               | 11.1                 | 10.1              | 10.1                | :+1:<sup>*</sup>  |\n| Firefox | 60                 | 67                   | 60                | 39                  | :+1:<sup>*</sup>  |\n| Edge    | 16                 | :x:                  | 16                | 14                  | :+1:<sup>*</sup>  |\n| IE      | :x:                | :x:                  | :x:               | :x:                 | 7 <sup>*</sup>     |\n\n<sup>*</sup> _Indicates support with `Promise` polyfill supplied_\n\n\n## Prior Art\n\n* [`dynamic-import-ponyfill`](https://www.npmjs.com/package/dynamic-import-ponyfill) – The \"first version\" of `dimport` – now deprecated.\n* [`shimport`](https://github.com/Rich-Harris/shimport) – Patient zero. Similar to \"nomodule\" mode. Made it \"okay\" to rewrite files on the fly.\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","_attachments":{},"homepage":"https://github.com/lukeed/dimport#readme","bugs":{"url":"https://github.com/lukeed/dimport/issues"},"license":"MIT"}