diff --git a/.gitignore b/.gitignore index 2ee0033..ffd9274 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ node_modules dist .DS_Store .idea -.__mf__win \ No newline at end of file +.__mf__win +lib +**/.__mf__temp \ No newline at end of file diff --git a/examples/nuxt-vite/nuxt-host/.__mf__temp/nuxhost/localSharedImportMap.js b/examples/nuxt-vite/nuxt-host/.__mf__temp/nuxhost/localSharedImportMap.js deleted file mode 100644 index 28a3aee..0000000 --- a/examples/nuxt-vite/nuxt-host/.__mf__temp/nuxhost/localSharedImportMap.js +++ /dev/null @@ -1,6 +0,0 @@ -// Windows temporarily needs this file, https://github.com/module-federation/vite/issues/68 - -const importMap = {}; -const usedShared = {}; -const usedRemotes = []; -export { usedShared, usedRemotes }; diff --git a/examples/nuxt-vite/nuxt-remote/.__mf__temp/nuxremote/localSharedImportMap.js b/examples/nuxt-vite/nuxt-remote/.__mf__temp/nuxremote/localSharedImportMap.js deleted file mode 100644 index 28a3aee..0000000 --- a/examples/nuxt-vite/nuxt-remote/.__mf__temp/nuxremote/localSharedImportMap.js +++ /dev/null @@ -1,6 +0,0 @@ -// Windows temporarily needs this file, https://github.com/module-federation/vite/issues/68 - -const importMap = {}; -const usedShared = {}; -const usedRemotes = []; -export { usedShared, usedRemotes }; diff --git a/lib/index.cjs b/lib/index.cjs deleted file mode 100644 index 4d75d20..0000000 --- a/lib/index.cjs +++ /dev/null @@ -1,1279 +0,0 @@ -var fs = require('fs'); -var path = require('pathe'); -var pluginutils = require('@rollup/pluginutils'); -var estreeWalker = require('estree-walker'); -var MagicString = require('magic-string'); -var defu = require('defu'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { return e[k]; } - }); - } - }); - } - n["default"] = e; - return n; -} - -var fs__namespace = /*#__PURE__*/_interopNamespace(fs); -var path__namespace = /*#__PURE__*/_interopNamespace(path); -var path__default = /*#__PURE__*/_interopDefaultLegacy(path); -var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString); - -var addEntry = function addEntry(_ref) { - var entryName = _ref.entryName, - entryPath = _ref.entryPath, - fileName = _ref.fileName; - var devEntryPath = entryPath.startsWith("virtual:mf") ? "/@id/" + entryPath : entryPath; - var entryFiles = []; - var htmlFilePath; - var _command; - return [{ - name: 'add-entry', - apply: "serve", - config: function config(_config, _ref2) { - var command = _ref2.command; - _command = command; - }, - configureServer: function configureServer(server) { - var _server$httpServer; - (_server$httpServer = server.httpServer) == null || _server$httpServer.once == null || _server$httpServer.once('listening', function () { - var port = server.config.server.port; - fetch(path__namespace.join("http://localhost:" + port, "" + devEntryPath))["catch"](function (e) {}); - }); - server.middlewares.use(function (req, res, next) { - if (!fileName) { - next(); - return; - } - if (req.url && req.url.startsWith(fileName.replace(/^\/?/, '/'))) { - req.url = devEntryPath; - } - next(); - }); - }, - transformIndexHtml: function transformIndexHtml(c) { - return c.replace('
', ""); - } - }, { - name: "add-entry", - enforce: "post", - configResolved: function configResolved(config) { - var inputOptions = config.build.rollupOptions.input; - if (!inputOptions) { - htmlFilePath = path__namespace.resolve(config.root, 'index.html'); - } else if (typeof inputOptions === 'string') { - entryFiles = [inputOptions]; - htmlFilePath = path__namespace.resolve(config.root, inputOptions); - } else if (Array.isArray(inputOptions)) { - entryFiles = inputOptions; - htmlFilePath = path__namespace.resolve(config.root, inputOptions[0]); - } else if (typeof inputOptions === 'object') { - entryFiles = Object.values(inputOptions); - htmlFilePath = path__namespace.resolve(config.root, Object.values(inputOptions)[0]); - } - }, - buildStart: function buildStart() { - if (_command === "serve") return; - var hasHash = fileName == null || fileName.includes == null ? void 0 : fileName.includes("[hash"); - var emitFileOptions = { - name: entryName, - type: 'chunk', - id: entryPath, - preserveSignature: 'strict' - }; - if (!hasHash) { - emitFileOptions.fileName = fileName; - } - this.emitFile(emitFileOptions); - if (htmlFilePath) { - var htmlContent = fs__namespace.readFileSync(htmlFilePath, 'utf-8'); - var scriptRegex = /"); - } - }, { - name: "add-entry", - enforce: "post", - configResolved: function configResolved(config) { - var inputOptions = config.build.rollupOptions.input; - if (!inputOptions) { - htmlFilePath = path.resolve(config.root, 'index.html'); - } else if (typeof inputOptions === 'string') { - entryFiles = [inputOptions]; - htmlFilePath = path.resolve(config.root, inputOptions); - } else if (Array.isArray(inputOptions)) { - entryFiles = inputOptions; - htmlFilePath = path.resolve(config.root, inputOptions[0]); - } else if (typeof inputOptions === 'object') { - entryFiles = Object.values(inputOptions); - htmlFilePath = path.resolve(config.root, Object.values(inputOptions)[0]); - } - }, - buildStart: function buildStart() { - if (_command === "serve") return; - var hasHash = fileName == null || fileName.includes == null ? void 0 : fileName.includes("[hash"); - var emitFileOptions = { - name: entryName, - type: 'chunk', - id: entryPath, - preserveSignature: 'strict' - }; - if (!hasHash) { - emitFileOptions.fileName = fileName; - } - this.emitFile(emitFileOptions); - if (htmlFilePath) { - var htmlContent = fs.readFileSync(htmlFilePath, 'utf-8'); - var scriptRegex = /`); - } - }, { - name: "add-entry", - enforce: "post", - configResolved(config) { - const inputOptions = config.build.rollupOptions.input; - if (!inputOptions) { - htmlFilePath = path.resolve(config.root, 'index.html'); - } else if (typeof inputOptions === 'string') { - entryFiles = [inputOptions]; - htmlFilePath = path.resolve(config.root, inputOptions); - } else if (Array.isArray(inputOptions)) { - entryFiles = inputOptions; - htmlFilePath = path.resolve(config.root, inputOptions[0]); - } else if (typeof inputOptions === 'object') { - entryFiles = Object.values(inputOptions); - htmlFilePath = path.resolve(config.root, Object.values(inputOptions)[0]); - } - }, - buildStart() { - if (_command === "serve") return; - const hasHash = fileName == null || fileName.includes == null ? void 0 : fileName.includes("[hash"); - const emitFileOptions = { - name: entryName, - type: 'chunk', - id: entryPath, - preserveSignature: 'strict' - }; - if (!hasHash) { - emitFileOptions.fileName = fileName; - } - this.emitFile(emitFileOptions); - if (htmlFilePath) { - const htmlContent = fs.readFileSync(htmlFilePath, 'utf-8'); - const scriptRegex = /"); - } - }, { - name: "add-entry", - enforce: "post", - configResolved: function configResolved(config) { - var inputOptions = config.build.rollupOptions.input; - if (!inputOptions) { - htmlFilePath = path__namespace.resolve(config.root, 'index.html'); - } else if (typeof inputOptions === 'string') { - entryFiles = [inputOptions]; - htmlFilePath = path__namespace.resolve(config.root, inputOptions); - } else if (Array.isArray(inputOptions)) { - entryFiles = inputOptions; - htmlFilePath = path__namespace.resolve(config.root, inputOptions[0]); - } else if (typeof inputOptions === 'object') { - entryFiles = Object.values(inputOptions); - htmlFilePath = path__namespace.resolve(config.root, Object.values(inputOptions)[0]); - } - }, - buildStart: function buildStart() { - if (_command === "serve") return; - var hasHash = fileName == null || fileName.includes == null ? void 0 : fileName.includes("[hash"); - var emitFileOptions = { - name: entryName, - type: 'chunk', - id: entryPath, - preserveSignature: 'strict' - }; - if (!hasHash) { - emitFileOptions.fileName = fileName; - } - this.emitFile(emitFileOptions); - if (htmlFilePath) { - var htmlContent = fs__namespace.readFileSync(htmlFilePath, 'utf-8'); - var scriptRegex = /