Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@originjs/vite-plugin-federation

Package Overview
Dependencies
Maintainers
5
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@originjs/vite-plugin-federation - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

90

dist/index.js

@@ -281,2 +281,8 @@ "use strict";

}
function getFileExtname(url) {
const fileNameAndParamArr = normalizePath(url).split("/");
const fileNameAndParam = fileNameAndParamArr[fileNameAndParamArr.length - 1];
const fileName = fileNameAndParam.split("?")[0];
return path.extname(fileName);
}
const REMOTE_FROM_PARAMETER = "remoteFrom";

@@ -418,3 +424,2 @@ const NAME_CHAR_REG = new RegExp("[0-9a-zA-Z@_-]+");

async transform(code, id) {
var _a;
if (builderInfo.isShared) {

@@ -452,13 +457,5 @@ for (const sharedInfo of parsedOptions.prodShared) {

if (!expose[1].emitFile) {
if (!expose[1].id) {
expose[1].id = (_a = await this.resolve(expose[1].import)) == null ? void 0 : _a.id;
if (!expose[1].id) {
this.error(
`Cannot find file ${expose[1].import}, please check your 'exposes.import' config.`
);
}
}
expose[1].emitFile = this.emitFile({
type: "chunk",
id: expose[1].id,
id: expose[1].id ?? expose[1].import,
name: EXPOSES_KEY_MAP.get(expose[0]),

@@ -502,3 +499,3 @@ preserveSignature: "allow-extension"

enter(node) {
var _a2, _b, _c, _d;
var _a, _b, _c, _d;
if (node.type === "ImportDeclaration") {

@@ -511,3 +508,3 @@ const moduleName = node.source.value;

let defaultImportDeclaration = null;
if (!((_a2 = node.specifiers) == null ? void 0 : _a2.length)) {
if (!((_a = node.specifiers) == null ? void 0 : _a.length)) {
magicString.remove(node.start, node.end);

@@ -517,4 +514,4 @@ modify = true;

node.specifiers.forEach((specify) => {
var _a3;
if ((_a3 = specify.imported) == null ? void 0 : _a3.name) {
var _a2;
if ((_a2 = specify.imported) == null ? void 0 : _a2.name) {
namedImportDeclaration.push(

@@ -689,3 +686,6 @@ `${specify.imported.name === specify.local.name ? specify.imported.name : `${specify.imported.name}:${specify.local.name}`}`

if (requiresRuntime || hasImportShared || modify) {
return magicString.toString();
return {
code: magicString.toString(),
map: magicString.generateMap({ hires: true })
};
}

@@ -704,6 +704,2 @@ }

);
const exposesModuleIdSet = /* @__PURE__ */ new Set();
EXPOSES_MAP.forEach((value) => {
exposesModuleIdSet.add(`${value}.js`);
});
let isHost;

@@ -917,5 +913,2 @@ let isRemote;

},
options() {
return null;
},
configResolved(config) {

@@ -1057,2 +1050,14 @@ viteConfigResolved = config;

}
const needHandleFileType = [
".js",
".ts",
".jsx",
".tsx",
".mjs",
".cjs",
".vue",
".svelte"
];
options.transformFileTypes = (options.transformFileTypes ?? []).concat(needHandleFileType).map((item) => item.toLowerCase());
const transformFileTypeSet = new Set(options.transformFileTypes);
let viteDevServer;

@@ -1188,2 +1193,6 @@ return {

}
const fileExtname = getFileExtname(id);
if (!transformFileTypeSet.has((fileExtname ?? "").toLowerCase())) {
return;
}
let ast = null;

@@ -1336,5 +1345,5 @@ try {

async function devSharedScopeCode(shared) {
const hostname = resolveHostname(viteDevServer.config.server);
const protocol = viteDevServer.config.server.https ? "https" : "http";
const port = viteDevServer.config.server.port ?? 5e3;
const serverConfiguration = viteDevServer.config.server;
const protocol = serverConfiguration.https ? "https" : "http";
const port = serverConfiguration.port ?? 5173;
const regExp = new RegExp(

@@ -1361,3 +1370,4 @@ `${normalizePath(viteDevServer.config.root)}[/\\\\]`

if (typeof obj === "object") {
const url = relativePath ? `'${protocol}://${hostname.name}:${port}${relativePath}'` : `'${protocol}://${hostname.name}:${port}/${cacheDir}/${sharedName}.js?'`;
const address = serverConfiguration.origin ?? `${protocol}://${resolveHost(serverConfiguration)}:${port}`;
const url = relativePath ? `'${address}${relativePath}'` : `'${address}/${cacheDir}/${sharedName}.js?'`;
str += `get:()=> get(${url}, ${REMOTE_FROM_PARAMETER})`;

@@ -1370,27 +1380,11 @@ res.push(`'${sharedName}':{'${obj.version}':{${str}}}`);

}
function resolveHostname(serverOptions) {
const optionsHost = serverOptions.host;
const optionOrigin = serverOptions.origin;
function resolveHost(serverOptions) {
const hostConfiguration = serverOptions.host;
let host;
if (optionsHost === void 0 || optionsHost === false || optionsHost === "localhost") {
host = "127.0.0.1";
} else if (optionsHost === true) {
host = void 0;
if (hostConfiguration === void 0 || typeof hostConfiguration === "boolean") {
host = "localhost";
} else {
host = optionsHost;
host = hostConfiguration;
}
let name;
if (optionOrigin) {
if (optionOrigin.includes("://")) {
const [, hostname] = optionOrigin.split("://");
name = hostname;
} else {
name = optionOrigin;
}
} else if (optionsHost !== "127.0.0.1" && host === "127.0.0.1" || host === "0.0.0.0" || host === "::" || host === void 0) {
name = "localhost";
} else {
name = host;
}
return { host, name };
return host;
}

@@ -1397,0 +1391,0 @@ }

{
"name": "@originjs/vite-plugin-federation",
"version": "1.2.1",
"version": "1.2.2",
"description": "A Vite plugin which support Module Federation.",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -21,2 +21,8 @@ /**

/**
* transform hook need to handle file types
* default ['.js','.ts','.jsx','.tsx','.mjs','.cjs','.vue','.svelte']
*/
transformFileTypes?: string[]
/**
* Options for library.

@@ -23,0 +29,0 @@ */

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc