{"bugs":{"url":"https://github.com/ScriptedAlchemy/webpack-external-import/issues"},"dist":{"shasum":"2082d11da0b235b5834e84c7a05d464f552f99af","tarball":"https://registry.npmjs.org/webpack-external-import/-/webpack-external-import-2.0.2-beta.4.tgz","fileCount":14,"integrity":"sha512-o7IB64jDdtDmPpH+H7l3vloJXyg9Uv3BU4uER7u9C0Ekr/wMNSD8IW3XpMyjlc7QuMEb81wDZIKvqjK6GHYpKg==","signatures":[{"sig":"MEYCIQC//D7UazXnx+BUMA4VFo1zpAfvBw7HK0c7/sK9mdTALgIhAJBU5FmFoMJoSVjjZc6zTi+tdJEcbEV6MQl752ZWDlVj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":119736,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeMhnbCRA9TVsSAnZWagAAJZ4P/1TiXcEJwucXiQIezplW\npyaxrCRb4KMSm/vebKkKAmZqEXYc4hxPEz0a6HXQ1mu9CNzR0S5mCGb4GeLX\ncbILA7O76Kzt8wK5NpPRFg1OoInDa39Qia/2ugHv1sLoSqpnNUQrps8NV6uw\n0sTqh8WAa2zs6Roe2z/75i0ymH63w1Valh3/U6ny7cRD5cxUT8ufoJX+BwtT\nsCYXZGvCMbRdIpwKLJwbXM2BHRnYrlr5CRQoawLuyn7MDPuGcuwFq0FTGomj\n93WPN22gfZzAf0+o+UevCjjQRGONG8dAs6WAkAC5OStqTcGt+KUhow5j5tzU\neDNyHOHDKKfGSEuaau5MgoV33P8YeHGgPbKjjFA8huuYG42xoZTUi3Shy/Vh\naO63uoPwYnnPx6VIwBfMQaZo/WHWcNNLnScJStle/tknwrOyUJRPzLAGM4QV\nYiaHftA8pndTsZmhN+vi/6ZM2PZn06TQIFByo/tmcrJO8z7AY8nIOJCr7rpC\nL4PWYQyF6UJRPgrI+s0C369DWgOq1HqPm8ESGiYA2xrd12KcRLkRMVu0gTXA\nN0h5W/hOGgsOzX8pThHWIZAavqra3LqzPNh/lV4N7m/ytUQ4roFZXBiIEfzH\nD0TfSa4czMOeseAU3dk5KE/hgzJzLeT4iyWO3wQFqCKFqCWxnBTdOXuWJ3CV\nod2H\r\n=QeQh\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"preset":"jest-puppeteer"},"name":"webpack-external-import","babel":{"plugins":["@babel/plugin-proposal-optional-chaining"],"presets":["@babel/preset-env","@babel/preset-react"]},"author":{"url":"https://github.com/ScriptedAlchemy","name":"Zack Jackson","email":"zack@ScriptedAlchemy.com"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Webpack External Import\n\n> **import() other chunks and modules from third parties, or other webpack builds themselves! At runtime!**\n\n<p align=\"center\">\n    \n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n  <a href=\"https://www.npmjs.com/package/webpack-external-import\">\n    <img src=\"https://img.shields.io/npm/v/webpack-external-import.svg\" alt=\"Version\" />\n  </a>\n\n  <a href=\"https://www.npmjs.com/package/webpack-external-import\">\n    <img src=\"https://img.shields.io/npm/dt/webpack-external-import.svg\" alt=\"Downloads\" />\n  </a>\n\n  <a href=\"https://www.npmjs.com/package/webpack-external-import\">\n    <img src=\"https://img.shields.io/npm/dm/webpack-external-import.svg\" alt=\"License\" />\n  </a>\n  \n  <a href=\"https://www.npmjs.com/package/webpack-external-import\">\n    <img src=\"https://img.shields.io/npm/l/webpack-external-import.svg\" alt=\"License\" />\n  </a>\n</p>\n\n<p align=\"center\">\n <img src=\"docs/webpack-external-import.png\" width=\"40%\" alt=\"webpack-external-import\" />\n</p>\n\n```shell\n$ yarn add webpack-external-import\n```\n\n_This project is under active development_\n\n\\*\\*To jump to the _development_ section [click here](#development)\n\n# Installation\n\n### npm\n\n```sh\nnpm install webpack-external-import --save\n```\n\n### Yarn\n\n```sh\nyarn add webpack-external-import\n```\n\n## Getting Started\n\n1.  Add `webpack-external-import/webpack` to your webpack plugins:\n\n```js\n// techblog.webpack.config.js\nconst URLImportPlugin = require(\"webpack-external-import/webpack\");\n{\n  plugins: [\n    new URLImportPlugin({\n      manifestName: \"website-one\"\n    })\n  ];\n}\n\n// otherblog.webpack.config\nconst URLImportPlugin = require(\"webpack-external-import/webpack\");\n{\n  plugins: [\n    new URLImportPlugin({\n      manifestName: \"website-two\"\n    })\n  ];\n}\n```\n\n2. If you are interleaving webpack bundles, load their manifests somewhere\n\n```js\n// index.js\nimport { corsImport } from \"webpack-external-import\";\nimport React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport App from \"./App.jsx\";\n\n// using Date.now() for cache busting the file. It should only less than 2kb\ncorsImport(`http://localhost:3002/importManifest.js?${Date.now()}`).then(() => {\n  ReactDOM.render(<App />, document.getElementById(\"app\"));\n});\n\n// you could also use native imports\n\nimport(\n  /* webpackIgnore:true */ `http://localhost:3002/importManifest.js?${Date.now()}`\n).then(() => {\n  ReactDOM.render(<App />, document.getElementById(\"app\"));\n});\n```\n\n## Usage\n\nThis plugin works with any Webpack driven application\n\n#### Vanilla JS\n\nThis assumes a import manifest was loaded somewhere else in the application already.\n\nIf you have not imported manifest then wrap your function in another promise:\n\n```js\ncorsImport(\"http://localhost:3002/importManifest.js\").then(() => {\n  someFunction();\n});\n```\n\nAs long as the `importManifest` was loaded - this is how it would be used\n`__webpack_require_.interleaved()` expects a module to contain both the module.id and the namespace\n\nThis allows external-import to know where to interleave from.\n`__webpack_require_.interleaved([namespace]/[module.id])`\n\nBelow is an example of interleaving a module from `website-2`\n\n```js\n// import a chunk from another website build with webpack-external-import\n\n__webpack_require__.interleaved(\"website-2/ValidationRules\").then(() => {\n  const validationRules = __webpack_require__(\"ValidationRules\");\n  // proceed to use as a you would with a normal require statement\n  validationRules.validateObject(someObject);\n});\n```\n\n### With JSX\n\n`ExternalComponent` exists for ease of use with React Components and is as SFC using React.Hooks\n\n```js\nimport { ExternalComponent } from \"webpack-external-import\";\nclass SomeComponent extends Component {\n  render() {\n    return (\n      <div>\n        <ExternalComponent\n          interleave={__webpack_require__\n            .interleaved(\"website-2/TitleComponent\")\n            .then(() => __webpack_require__(\"TitleComponent\"))}\n          export=\"Title\"\n          title=\"Some Heading\"\n        />\n      </div>\n    );\n  }\n}\n```\n\n## What is the use of `webpack-external-import` ?\n\n- **Load components over the wire** - Pull in components at runtime.\n- **Build leaner micro-frontends (MFE)** -\n  Micro-frontends can share bundle chunks and resources with each other while remaining self-contained, removing needless code duplication.\n- **Split a large, multi-team app into separate deployable chunks while keeping it as one SPA** - Large apps can be split into separate feature bundles that can be deployed independently, reducing deployment bottlenecks.\n- **Manage common js/vendor files automatically.** - Instead of dealing with peer dependencies, externals, or anything else, you can load the dependency from a remote source.\n- **LOSA Style frontend architecture** - Run multiple apps on a single page.\n- **FOSA Style frontend orchestration** - Powerful frontend orchestration, self-organizing application architecture. Many builds act as one\n\n### Advanced Setup - Injecting Webpack modules from another build\n\nUse the webpack plugin to inject webpack modules from another build into your build.\n\n_**Important**: Make sure manifestName_ is unique per webpack build.\nIf you have multiple builds, they all need to have a unique manifestName\n\n**webpack.config.js**\n\n```js\nconst URLImportPlugin = require(\"webpack-external-import/webpack\");\n{\n  plugins: [\n    new URLImportPlugin({\n      manifestName: \"website-one\"\n    })\n  ];\n}\n```\n\n## Mark Files for interleaving\n\nPretend we have two separate apps that each have their _independent_ build. We want to share a module from one of our apps with the other.\n\nTo do this, you must add an `externalize` object to `package.json`.\nThe `externalize` object tells the plugin to make the module accessible through a predictable name.\n\nFor example:\n\n```json\n// wbsite-two package.json\n{\n  \"name\": \"some-package-name\",\n  \"interleave\": {\n    \"src/components/Title/index.js\": \"TitleComponent\",\n    \"src/components/hello-world/index.js\": \"SomeExternalModule\"\n  }\n}\n```\n\n```js\n// website-one App.js\n__webpack_require__\n  .interleaved(\"website-3/TitleComponentWithCSSFile\")\n  .then(() => __webpack_require__(\"TitleComponentWithCSSFile\"));\n```\n\nThis ensures a easy way for other consumers, teams, engineers to look up what another project or team is willing\nto allow for interleaving\n\n## Full Example\n\nWEBSITE-ONE\napp.js\n\n```js\nimport React, { Component } from \"react\";\nimport { ExternalComponent } from \"webpack-external-import\";\nimport HelloWorld from \"./components/goodbye-world\";\nimport \"react-select\";\n\nclass App extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {\n      titleUrl: null,\n      manifestLoaded: false,\n      loaded: false\n    };\n  }\n\n  componentDidMount() {\n    __webpack_require__\n      .interleaved(\"website-3/TitleComponentWithCSSFile\")\n      .then(() => __webpack_require__(\"TitleComponentWithCSSFile\"));\n  }\n\n  renderDynamic = () => {\n    const { loaded } = this.state;\n    if (!loaded) return null;\n    return __webpack_require__(\"SomeExternalModule\").default();\n  };\n\n  render() {\n    return (\n      <div>\n        <HelloWorld />\n\n        <ExternalComponent\n          interleave={__webpack_require__\n            .interleaved(\"website-2/TitleComponent\")\n            .then(() => __webpack_require__(\"TitleComponent\"))}\n          export=\"Title\"\n          module=\"TitleComponent\"\n          title=\"Some Heading\"\n        />\n\n        <ExternalComponent\n          interleave={__webpack_require__\n            .interleaved(\"website-3/TitleComponentWithCSSFile\")\n            .then(() => __webpack_require__(\"TitleComponentWithCSSFile\"))}\n          export=\"Title\"\n          title=\"Title Component With CSS File Import\"\n        />\n        {this.renderDynamic()}\n      </div>\n    );\n  }\n}\n\nPromise.all([\n  corsImport(`http://localhost:3002/importManifest.js?${Date.now()}`),\n  corsImport(`http://localhost:3003/importManifest.js?${Date.now()}`)\n]).then(() => {\n  ReactDOM.render(<App />, document.getElementById(\"app\"));\n});\n```\n\nWEBSITE-TWO:\npackage.json\n\n```json\n{\n  \"name\": \"website-two\",\n  \"version\": \"0.0.0-development\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/faceyspacey/remixx.git\"\n  },\n  \"author\": \"Zack Jackson <zack@ScriptedAlchemy.com> (https://github.com/ScriptedAlchemy)\",\n  \"interleave\": {\n    \"src/components/Title/index.js\": \"TitleComponentWithCSSFile\",\n    \"src/components/Title/style.css\": \"TitleComponentWithCSSFileCSS\",\n    \"src/components/hello-world/index.js\": \"SomeExternalModule\"\n  }\n}\n```\n\n## API:\n\n```js\n// Website Two -  webpack.config.js\n\nmodule.exports = {\n  output: {\n    publicPath\n  },\n  plugins: [\n    new URLImportPlugin({\n      manifestName: \"website-two\",\n      fileName: \"importManifest.js\",\n      basePath: ``,\n      publicPath: `//localhost:3002/`,\n      transformExtensions: /^(gz|map)$/i,\n      writeToFileEmit: false,\n      seed: null,\n      filter: null,\n      debug: true,\n      map: null,\n      generate: null,\n      sort: null\n    })\n  ]\n};\n\n// Website One webpack.config.js\nmodule.exports = {\n  output: {\n    publicPath\n  },\n  plugins: [\n    new URLImportPlugin({\n      manifestName: \"website-one\",\n      fileName: \"importManifest.js\",\n      basePath: ``,\n      publicPath: `//localhost:3001/`,\n      transformExtensions: /^(gz|map)$/i,\n      writeToFileEmit: false,\n      seed: null,\n      filter: null,\n      debug: true,\n      map: null,\n      generate: null,\n      sort: null\n    })\n  ]\n};\n```\n\n### `options.fileName`\n\nType: `String`<br>\nDefault: `manifest.json`\n\nThe manifest filename in your output directory.\n\n### `options.publicPath`\n\nType: `String`\nDefault: `output.publicPath`\n\nA path prefix that will be added to values of the manifest.\n\n### `options.basePath`\n\nType: `String`\n\nA path prefix for all keys. Useful for including your output path in the manifest.\n\n### `options.writeToFileEmit`\n\nType: `Boolean`<br>\nDefault: `false`\n\nIf set to `true` will emit to build folder and memory in combination with `webpack-dev-server`\n\n### `options.seed`\n\nType: `Object`<br>\nDefault: `{}`\n\nA cache of key/value pairs to used to seed the manifest. This may include a set of [custom key/value](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json) pairs to include in your manifest or may be used to combine manifests across compilations in [multi-compiler mode](https://github.com/webpack/webpack/tree/master/examples/multi-compiler). To combine manifests, pass a shared seed object to each compiler's ManifestPlugin instance.\n\n### `options.filter`\n\nType: `Function(FileDescriptor): Boolean`\n\n### `options.test`\n\nType: `Function(Object, FileDescriptor): Object`<br>\nDefault: `src`\n\nTest resource path to see if plugin should apply transformations\n\n### `options.map`\n\nType: `Function(FileDescriptor): FileDescriptor`\n\nModify files details before the manifest is created. [FileDescriptor typings](#filedescriptor)\n\n### `options.sort`\n\nType: `Function(FileDescriptor): number`\n\nSort files before they are passed to `generate`. [FileDescriptor typings](#filedescriptor)\n\n### `options.generate`\n\nType: `Function(Object, FileDescriptor): Object`<br>\nDefault: `(seed, files) => files.reduce((manifest, {name, path}) => ({...manifest, [name]: path}), seed)`\n\nCreate the manifest. It can return anything as long as it's serializable by `JSON.stringify`. [FileDescriptor typings](#filedescriptor)\n\n### `options.serialize`\n\nType: `Function(Object): string`<br>\nDefault: `(manifest) => JSON.stringify(manifest, null, 2)`\n\nOutput manifest file in a different format then json (i.e., yaml).\n\n### **ExternalComponent**\n\nReact Component\n\n#### **Props**:\n\n**`src`: string** - a url to a javascript file, note it will need to be built by another webpack build running this plugin\n\n**`interleave`: function** - the `__webpack_require__.interleave()` function, which will return a module\n\n**`export`: string** - The named export to use as a component from the module being imported\n\n### The entry manifest\n\nEach webpack build using the webpack plugin emits a manifest file to the build output directory.\n\nThe manifest allows you to find a chunk that you want, even if the name has been hashed.\n\nBelow is an example of using the manifest.\n\nIn this file, I am importing code from another website/build. My application is loading website two's manifest, which is automatically added to `window.entryManifest` under the `manifestName` I set in the webpack plugin. After that, I'm importing a chunk from website-two, in this case - the chunk is code-split.\n\n```js\ncomponentDidMount() {\n  corsImport('http://localhost:3002/importManifest.js').then(() => {\n      const Title = __webpack_require__\n        .interleaved(\"website-two/TitleComponent\")\n        .then(() => __webpack_require__(\"TitleComponent\"))\n\n        console.log(Title) // => Module {default: ()=>{}, Title: ()=>{}}\n  });\n}\n```\n\n## DEMO\n\nHow to start using the demo\nIn the _root directory_, run the following\n\n1. run `yarn install`\n2. run `yarn demo` from the root directory\n3. browse to [localhost:3001](http://localhost:3001) and you will see components from two other websites\n\nThis command will install, all dependencies, build the source for the plugin, install the demo dependencies, run all builds and start serving\n\n## Development & Debugging\n\nHow to start the demo in debug mode, using node --inspect and connecting to a chrome debugger\n\n> This is mainly for debugging the webpack plugin\n\nIn the root directory, run the following\n\n1. `yarn install`\n2. `yarn demo:debug` from the root directory\n3. browse to [localhost:3001](http://localhost:3001)\n\n**Note:** _[localhost:3001](http://localhost:3001) is the \"consumer app, while the other is the provider app\". Both apps work independently and you should check both of them out (they are extremely basic)_\n\nOpen chrome dev tools and you should see the box highlighted below appear, click on it to connect to the webpack debugger\n![GitHub Logo](/docs/inspect.png)\n","gitHead":"52802d005e1b4cd5e51b4d3eba459eea76f3f1da","license":"GPL-3.0-only","scripts":{"demo":"yarn && yarn link webpack-external-import && concurrently \"yarn compile\" \"yarn link\" \"yarn demo:one\"  \"yarn demo:two\"  \"yarn demo:three\"","jest":"NODE_ENV=test jest","lint":"eslint --ext .js,.ts,.tsx src --fix","test":"yarn  lint","babel":"yarn compile && cd manual && yarn babel","commit":"npx git-cz","compile":"babel src -d .","decrypt":"node decrypt.js","encrypt":"node encrypt.js","jest:ci":"cross-env NODE_ENV=development jest","prepare":"yarn compile && cd manual && yarn","demo:one":"cd manual; yarn && cd Website1; yarn && yarn link \"webpack-external-import\" && yarn manual:dev","demo:two":"cd manual/Website2; yarn && yarn link \"webpack-external-import\" && yarn manual:dev","demo:fast":"yarn compile && yarn link && yarn demo:one:fast | yarn demo:two:fast","demo:prod":"yarn && yarn compile && yarn link && yarn demo:one:prod | yarn demo:two:prod","demo:debug":"yarn && yarn link webpack-external-import && concurrently \"yarn kill-ports\" \"yarn compile\" \"yarn link\" \"yarn demo:one\" \"yarn demo:two\" \"yarn demo:three:debug\"","demo:three":"cd manual/Website3; yarn && yarn link \"webpack-external-import\" && yarn manual:dev","kill-ports":"lsof -ti:3001 | xargs kill -9; lsof -ti:3002 | xargs kill -9; lsof -ti:3003 | xargs kill -9","demo:one:prod":"cd manual/Website1; yarn && yarn link \"webpack-external-import\" && yarn manual:prod","demo:two:prod":"cd manual/Website2; yarn && yarn link \"webpack-external-import\" && yarn manual:prod","demo:two:debug":"cd manual/Website2; yarn && yarn link \"webpack-external-import\" && yarn manual:debug","demo:three:prod":"cd manual/Website3; yarn && yarn link \"webpack-external-import\" && yarn manual:prod","demo:three:debug":"cd manual/Website3; yarn && yarn link \"webpack-external-import\" && yarn manual:debug","semantic-release":"semantic-release"},"_npmUser":{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"},"homepage":"https://github.com/ScriptedAlchemy/webpack-external-import#readme","keywords":["import url","dynamic imports url","over the wire","import() url","external url import","script injection","webpack import url","webpack","manifest","dynamic dll plugin","dll plugin","runtime"],"repository":{"url":"git+https://github.com/ScriptedAlchemy/webpack-external-import.git","type":"git"},"_npmVersion":"6.13.4","description":"dynamic import() external urls!","directories":{},"maintainers":[{"name":"zackljackson","email":"zackary.l.jackson@gmail.com"}],"_nodeVersion":"10.18.1","dependencies":{"assert":"^2.0.0","loadjs":"^4.2.0","pkg-up":"^3.1.0","dimport":"^1.0.0","fs-extra":"^8.1.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"24.9.0","react":"16.8.6","eslint":"6.8.0","marked":"0.8.0","webpack":"4.41.5","flow-bin":"0.117.0","prettier":"1.19.1","cross-env":"7.0.0","puppeteer":"1.20.0","react-dom":"16.8.6","@babel/cli":"7.7.7","babel-core":"7.0.0-bridge.0","commitizen":"4.0.3","prop-types":"15.7.2","source-map":"0.7.3","@babel/core":"7.7.7","babel-watch":"7.0.0","node-cipher":"6.3.3","webpack-cli":"3.3.10","babel-eslint":"10.0.3","babel-loader":"8.0.6","concurrently":"5.1.0","jest-resolve":"24.9.0","schema-utils":"2.6.1","jest-haste-map":"24.9.0","jest-puppeteer":"4.4.0","@babel/traverse":"7.7.4","semantic-release":"17.0.1","@babel/preset-env":"7.7.7","webpack-dev-server":"3.10.1","@babel/preset-react":"7.7.4","eslint-plugin-react":"7.17.0","html-webpack-plugin":"3.2.0","regenerator-runtime":"0.13.3","eslint-config-airbnb":"18.0.1","eslint-plugin-import":"2.19.1","travis-github-status":"1.6.3","eslint-config-prettier":"6.10.0","eslint-plugin-jsx-a11y":"6.2.3","eslint-plugin-prettier":"3.1.2","cz-conventional-changelog":"3.1.0","eslint-plugin-react-hooks":"^2.3.0","@babel/helper-module-imports":"7.7.4","@babel/plugin-transform-runtime":"7.7.6","@babel/plugin-transform-react-jsx":"7.7.7","@babel/plugin-syntax-dynamic-import":"7.7.4","@babel/plugin-proposal-class-properties":"7.7.4","@babel/plugin-proposal-optional-chaining":"7.7.5"},"peerDependencies":{"webpack":"^4.40.2"},"_npmOperationalInternal":{"tmp":"tmp/webpack-external-import_2.0.2-beta.4_1580341723057_0.48831575588948817","host":"s3://npm-registry-packages"},"_id":"webpack-external-import@2.0.2-beta.4","version":"2.0.2-beta.4"}