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

@softarc/native-federation

Package Overview
Dependencies
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@softarc/native-federation - npm Package Compare versions

Comparing version 2.0.13 to 2.0.14

src/lib/core/default-server-deps-list.d.ts

4

package.json
{
"name": "@softarc/native-federation",
"version": "2.0.13",
"version": "2.0.14",
"type": "commonjs",

@@ -9,3 +9,3 @@ "license": "MIT",

"npmlog": "^6.0.2",
"@softarc/native-federation-runtime": "2.0.13"
"@softarc/native-federation-runtime": "2.0.14"
},

@@ -12,0 +12,0 @@ "main": "./src/index.js",

@@ -1,2 +0,2 @@

import { SkipList } from '../core/default-skip-list';
import { PreparedSkipList, SkipList } from '../core/default-skip-list';
import { MappedPath } from '../utils/mapped-paths';

@@ -9,2 +9,4 @@ export interface SharedConfig {

includeSecondaries?: boolean;
transient?: boolean;
platform?: 'browser' | 'node';
packageInfo?: {

@@ -29,2 +31,3 @@ entryPoint: string;

includeSecondaries?: boolean;
platform: 'browser' | 'node';
packageInfo?: {

@@ -41,2 +44,3 @@ entryPoint: string;

sharedMappings: Array<MappedPath>;
skip: PreparedSkipList;
}

@@ -74,17 +74,18 @@ "use strict";

const files = fs.readdirSync(libPath);
const dirs = files
const secondaries = files
.map((f) => path.join(libPath, f))
.filter((f) => fs.lstatSync(f).isDirectory() && f !== 'node_modules');
const secondaries = dirs.filter((d) => fs.existsSync(path.join(d, 'package.json')));
for (const s of secondaries) {
const secondaryLibName = s
.replace(/\\/g, '/')
.replace(/^.*node_modules[/]/, '');
if (excludes.includes(secondaryLibName)) {
continue;
if (fs.existsSync(path.join(s, 'package.json'))) {
const secondaryLibName = s
.replace(/\\/g, '/')
.replace(/^.*node_modules[/]/, '');
if (excludes.includes(secondaryLibName)) {
continue;
}
if ((0, default_skip_list_1.isInSkipList)(secondaryLibName, default_skip_list_1.PREPARED_DEFAULT_SKIP_LIST)) {
continue;
}
acc[secondaryLibName] = Object.assign({}, shareObject);
}
if ((0, default_skip_list_1.isInSkipList)(secondaryLibName, default_skip_list_1.PREPARED_DEFAULT_SKIP_LIST)) {
continue;
}
acc[secondaryLibName] = Object.assign({}, shareObject);
_findSecondaries(s, excludes, shareObject, acc);

@@ -225,8 +226,12 @@ }

}
function findTransientDeps(packageNames, projectRoot, preparedSkipList) {
function findTransientDeps(configuredShareObjects, projectRoot, preparedSkipList) {
const discovered = new Set();
const result = [];
const packageNames = Object.keys(configuredShareObjects);
for (const packageName of packageNames) {
const packagePath = path.join(projectRoot, 'node_modules', packageName, 'package.json');
_findTransientDeps(packagePath, projectRoot, preparedSkipList, discovered, result);
const shareConfig = configuredShareObjects[packageName];
if (typeof shareConfig === 'object' && shareConfig.transient) {
const packagePath = path.join(projectRoot, 'node_modules', packageName, 'package.json');
_findTransientDeps(packagePath, projectRoot, preparedSkipList, discovered, result);
}
}

@@ -262,6 +267,5 @@ return result;

const packagePath = findPackageJson(projectPath);
const sharedPackageNames = Object.keys(configuredShareObjects);
const packageDirectory = path.dirname(packagePath);
const preparedSkipList = (0, default_skip_list_1.prepareSkipList)(skipList);
const transientDeps = findTransientDeps(sharedPackageNames, packageDirectory, preparedSkipList);
const transientDeps = findTransientDeps(configuredShareObjects, packageDirectory, preparedSkipList);
const transientShareObject = transientDeps.reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr.packageName]: { path: curr.packagePath } })), {});

@@ -268,0 +272,0 @@ const shareObjects = Object.assign(Object.assign({}, configuredShareObjects), transientShareObject);

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

const logger_1 = require("../utils/logger");
const default_server_deps_list_1 = require("../core/default-server-deps-list");
function withNativeFederation(config) {

@@ -17,2 +18,3 @@ var _a, _b, _c;

sharedMappings: normalizeSharedMappings(config, skip),
skip
};

@@ -28,2 +30,3 @@ }

requiredVersion: 'auto',
platform: 'browser',
});

@@ -33,3 +36,3 @@ }

result = Object.keys(shared).reduce((acc, cur) => {
var _a, _b, _c;
var _a, _b, _c, _d;
return (Object.assign(Object.assign({}, acc), { [cur]: {

@@ -42,2 +45,3 @@ requiredVersion: (_a = shared[cur].requiredVersion) !== null && _a !== void 0 ? _a : 'auto',

packageInfo: shared[cur].packageInfo,
platform: (_d = shared[cur].platform) !== null && _d !== void 0 ? _d : getDefaultPlatform(cur)
} }));

@@ -58,3 +62,4 @@ }, {});

});
const result = paths.filter((p) => !(0, default_skip_list_1.isInSkipList)(p.key, skip) && !p.key.includes('*'));
const result = paths
.filter((p) => !(0, default_skip_list_1.isInSkipList)(p.key, skip) && !p.key.includes('*'));
if (paths.find((p) => p.key.includes('*'))) {

@@ -65,2 +70,10 @@ logger_1.logger.warn('Sharing mapped paths with wildcards (*) not supported');

}
function getDefaultPlatform(cur) {
if (default_server_deps_list_1.DEFAULT_SERVER_DEPS_SET.has(cur)) {
return 'node';
}
else {
return 'browser';
}
}
//# sourceMappingURL=with-native-federation.js.map

@@ -19,2 +19,3 @@ import { MappedPath } from '../utils/mapped-paths';

hash: boolean;
platform?: 'browser' | 'node';
}

@@ -21,0 +22,0 @@ export interface BuildResult {

@@ -22,3 +22,6 @@ "use strict";

: artefactInfo.exposes;
const sharedPackageInfo = yield (0, bundle_shared_1.bundleShared)(config, fedOptions, externals);
const { sharedBrowser, sharedServer } = splitShared(config.shared);
const sharedPackageInfoBrowser = yield (0, bundle_shared_1.bundleShared)(sharedBrowser, config, fedOptions, externals, 'browser');
const sharedPackageInfoServer = yield (0, bundle_shared_1.bundleShared)(sharedServer, config, fedOptions, externals, 'node');
const sharedPackageInfo = [...sharedPackageInfoBrowser, ...sharedPackageInfoServer];
const sharedMappingInfo = !artefactInfo

@@ -38,2 +41,18 @@ ? (0, bundle_exposed_and_mappings_1.describeSharedMappings)(config, fedOptions)

}
function splitShared(shared) {
const sharedServer = {};
const sharedBrowser = {};
for (const key in shared) {
if (shared[key].platform === 'node') {
sharedServer[key] = shared[key];
}
else {
sharedBrowser[key] = shared[key];
}
}
return {
sharedBrowser,
sharedServer
};
}
//# sourceMappingURL=build-for-federation.js.map

@@ -1,4 +0,4 @@

import { NormalizedFederationConfig } from '../config/federation-config';
import { NormalizedFederationConfig, NormalizedSharedConfig } from '../config/federation-config';
import { SharedInfo } from '@softarc/native-federation-runtime';
import { FederationOptions } from './federation-options';
export declare function bundleShared(config: NormalizedFederationConfig, fedOptions: FederationOptions, externals: string[]): Promise<Array<SharedInfo>>;
export declare function bundleShared(sharedBundles: Record<string, NormalizedSharedConfig>, config: NormalizedFederationConfig, fedOptions: FederationOptions, externals: string[], platform?: 'browser' | 'node'): Promise<Array<SharedInfo>>;

@@ -13,4 +13,4 @@ "use strict";

const crypto_1 = tslib_1.__importDefault(require("crypto"));
function bundleShared(config, fedOptions, externals) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
function bundleShared(sharedBundles_1, config_1, fedOptions_1, externals_1) {
return tslib_1.__awaiter(this, arguments, void 0, function* (sharedBundles, config, fedOptions, externals, platform = 'browser') {
const folder = fedOptions.packageJson

@@ -21,9 +21,9 @@ ? path.dirname(fedOptions.packageJson)

fs.mkdirSync(cachePath, { recursive: true });
const inferedPackageInfos = Object.keys(config.shared)
.filter((packageName) => !config.shared[packageName].packageInfo)
const inferedPackageInfos = Object.keys(sharedBundles)
.filter((packageName) => !sharedBundles[packageName].packageInfo)
.map((packageName) => (0, package_info_1.getPackageInfo)(packageName, folder))
.filter((pi) => !!pi);
const configuredPackageInfos = Object.keys(config.shared)
.filter((packageName) => !!config.shared[packageName].packageInfo)
.map((packageName) => (Object.assign({ packageName }, config.shared[packageName].packageInfo)));
const configuredPackageInfos = Object.keys(sharedBundles)
.filter((packageName) => !!sharedBundles[packageName].packageInfo)
.map((packageName) => (Object.assign({ packageName }, sharedBundles[packageName].packageInfo)));
const packageInfos = [...inferedPackageInfos, ...configuredPackageInfos];

@@ -62,2 +62,3 @@ const configState = fs.readFileSync(path.join(__dirname, '../../../package.json')) +

hash: false,
platform,
});

@@ -92,3 +93,3 @@ for (const fileName of exptedResults) {

return packageInfos.map((pi) => {
const shared = config.shared[pi.packageName];
const shared = sharedBundles[pi.packageName];
return {

@@ -95,0 +96,0 @@ packageName: pi.packageName,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExternals = getExternals;
// import { isInSkipList, PREPARED_DEFAULT_SKIP_LIST } from './default-skip-list';
function getExternals(config) {
const shared = Object.keys(config.shared);
const sharedMappings = config.sharedMappings.map((m) => m.key);
const externals = [...shared, ...sharedMappings];
// TODO: Also handle deps that match RegExps and functions
const depsToSkip = config.skip.strings;
const externals = [...shared, ...sharedMappings, ...depsToSkip];
return externals;
// return externals.filter((p) => !isInSkipList(p, PREPARED_DEFAULT_SKIP_LIST));
}
//# sourceMappingURL=get-externals.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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