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

@module-federation/dts-plugin

Package Overview
Dependencies
Maintainers
7
Versions
529
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/dts-plugin - npm Package Compare versions

Comparing version 0.8.8 to 0.8.9

dist/DTSManagerOptions-c74c59ed.d.ts

17

dist/CHANGELOG.md
# @module-federation/dts-plugin
## 0.8.9
### Patch Changes
- 6e3afc6: feat(dts-plugin): support pass headers when request types url
- 1be9d62: feat(dts-plugin): add dts.displayErrorInTerminal to help control display error
- 6e3afc6: fix(dts-plugin): set outputDir default value
- 6e3afc6: fix(dts-plugin): use remoteTarPath first to fetch hot types
- 6e3afc6: fix(dts-plugin): only consume types in dev
- 6e3afc6: fix(dts-plugin): throw error while downloading types archive hit historyApiFallback
- 6e3afc6: fix(dts-plugin): generateTypes should after consumeTypes finished
- 6e3afc6: fix(dts-plugin): dev plugin should apply after fetchPromise resolved
- @module-federation/sdk@0.8.9
- @module-federation/managers@0.8.9
- @module-federation/third-party-dts-extractor@0.8.9
- @module-federation/error-codes@0.8.9
## 0.8.8

@@ -4,0 +21,0 @@

6

dist/core.d.ts

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

import { D as DTSManager, T as TsConfigJson, R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-1bad6327.js';
export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-1bad6327.js';
import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-92108ee8.js';
import { D as DTSManager, T as TsConfigJson, R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-484d9f4a.js';
export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-484d9f4a.js';
import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
import { moduleFederationPlugin } from '@module-federation/sdk';

@@ -5,0 +5,0 @@ import { ChildProcess } from 'child_process';

@@ -6,3 +6,3 @@ import {

rpc_exports
} from "./chunk-PZ7TR7QG.js";
} from "./chunk-2B3WPOMZ.js";
import {

@@ -23,3 +23,3 @@ DTSManager,

validateOptions
} from "./chunk-M7Q7FIFW.js";
} from "./chunk-7XB7PFWZ.js";
import "./chunk-KCWHOFI6.js";

@@ -26,0 +26,0 @@ import "./chunk-4CSLH7II.js";

import {
rpc_exports
} from "./chunk-PZ7TR7QG.js";
} from "./chunk-2B3WPOMZ.js";
import {

@@ -12,3 +12,3 @@ ModuleFederationDevServer,

retrieveTypesZipPath
} from "./chunk-M7Q7FIFW.js";
} from "./chunk-7XB7PFWZ.js";
import {

@@ -15,0 +15,0 @@ fileLog,

@@ -5,3 +5,3 @@ import {

generateTypes
} from "./chunk-M7Q7FIFW.js";
} from "./chunk-7XB7PFWZ.js";
import "./chunk-KCWHOFI6.js";

@@ -8,0 +8,0 @@ import {

@@ -5,3 +5,3 @@ import {

rpc_exports
} from "./chunk-PZ7TR7QG.js";
} from "./chunk-2B3WPOMZ.js";
import {

@@ -13,3 +13,3 @@ cloneDeepOptions,

validateOptions
} from "./chunk-M7Q7FIFW.js";
} from "./chunk-7XB7PFWZ.js";
import {

@@ -30,2 +30,3 @@ getIPV4,

import fs from "fs-extra";
import path4 from "path";

@@ -50,4 +51,4 @@ // packages/dts-plugin/src/dev-worker/createDevWorker.ts

removeUnSerializationOptions() {
var _a2, _b, _c, _d;
(_b = (_a2 = this._options.host) == null ? void 0 : _a2.moduleFederationConfig) == null ? true : delete _b.manifest;
var _a, _b, _c, _d;
(_b = (_a = this._options.host) == null ? void 0 : _a.moduleFederationConfig) == null ? true : delete _b.manifest;
(_d = (_c = this._options.remote) == null ? void 0 : _c.moduleFederationConfig) == null ? true : delete _d.manifest;

@@ -59,4 +60,4 @@ }

update() {
var _a2, _b;
(_b = (_a2 = this._rpcWorker.process) == null ? void 0 : _a2.send) == null ? void 0 : _b.call(_a2, {
var _a, _b;
(_b = (_a = this._rpcWorker.process) == null ? void 0 : _a.send) == null ? void 0 : _b.call(_a, {
type: rpc_exports.RpcGMCallTypes.CALL,

@@ -71,4 +72,4 @@ id: this._rpcWorker.id,

exit() {
var _a2;
(_a2 = this._rpcWorker) == null ? void 0 : _a2.terminate();
var _a;
(_a = this._rpcWorker) == null ? void 0 : _a.terminate();
}

@@ -99,5 +100,5 @@ };

import { normalizeOptions, TEMP_DIR as BasicTempDir } from "@module-federation/sdk";
import path3 from "path";
// packages/dts-plugin/src/plugins/utils.ts
import path3 from "path";
function isDev() {

@@ -107,2 +108,14 @@ return process.env["NODE_ENV"] === "development";

__name(isDev, "isDev");
function isPrd() {
return process.env["NODE_ENV"] === "production";
}
__name(isPrd, "isPrd");
function getCompilerOutputDir(compiler) {
try {
return path3.relative(compiler.context, compiler.outputPath || compiler.options.output.path);
} catch (err) {
return "";
}
}
__name(getCompilerOutputDir, "getCompilerOutputDir");

@@ -117,3 +130,3 @@ // packages/dts-plugin/src/plugins/DevPlugin.ts

try {
const dir = path3.dirname(filePath);
const dir = path4.dirname(filePath);
fs.ensureDirSync(dir);

@@ -125,11 +138,15 @@ } catch (_err) {

var _DevPlugin = class _DevPlugin {
constructor(options) {
constructor(options, dtsOptions, fetchTypesPromise) {
__publicField(this, "name", "MFDevPlugin");
__publicField(this, "_options");
__publicField(this, "_devWorker");
__publicField(this, "dtsOptions");
__publicField(this, "fetchTypesPromise");
this._options = options;
this.fetchTypesPromise = fetchTypesPromise;
this.dtsOptions = dtsOptions;
}
static ensureLiveReloadEntry(options, filePath) {
ensureTempDir(filePath);
const liveReloadEntry = fs.readFileSync(path3.join(__dirname, "./iife/launch-web-client.js")).toString("utf-8");
const liveReloadEntry = fs.readFileSync(path4.join(__dirname, "./iife/launch-web-client.js")).toString("utf-8");
const liveReloadEntryWithOptions = liveReloadEntry.replace(WEB_CLIENT_OPTIONS_IDENTIFIER, JSON.stringify(options));

@@ -161,11 +178,12 @@ fs.writeFileSync(filePath, liveReloadEntryWithOptions);

_exit(exitCode = 0) {
var _a2;
(_a2 = this._devWorker) == null ? void 0 : _a2.exit();
var _a;
(_a = this._devWorker) == null ? void 0 : _a.exit();
process.exit(exitCode);
}
_afterEmit() {
var _a2;
(_a2 = this._devWorker) == null ? void 0 : _a2.update();
var _a;
(_a = this._devWorker) == null ? void 0 : _a.update();
}
apply(compiler) {
var _a;
const { _options: { name, dev, dts } } = this;

@@ -193,7 +211,7 @@ new compiler.webpack.DefinePlugin({

}
this._options.runtimePlugins.push(path3.resolve(__dirname, "dynamic-remote-type-hints-plugin.js"));
this._options.runtimePlugins.push(path4.resolve(__dirname, "dynamic-remote-type-hints-plugin.js"));
}
if (!normalizedDev.disableLiveReload) {
const TEMP_DIR = path3.join(`${process.cwd()}/node_modules`, BasicTempDir);
const filepath = path3.join(TEMP_DIR, `live-reload.js`);
const TEMP_DIR = path4.join(`${process.cwd()}/node_modules`, BasicTempDir);
const filepath = path4.join(TEMP_DIR, `live-reload.js`);
if (typeof compiler.options.entry === "object") {

@@ -221,3 +239,4 @@ _DevPlugin.ensureLiveReloadEntry({

consumeTypes: defaultConsumeTypes,
extraOptions: {}
extraOptions: {},
displayErrorInTerminal: (_a = this.dtsOptions) == null ? void 0 : _a.displayErrorInTerminal
}, "mfOptions.dts")(dts);

@@ -228,3 +247,3 @@ const normalizedGenerateTypes = normalizeOptions(Boolean(normalizedDtsOptions), defaultGenerateTypes, "mfOptions.dts.generateTypes")(normalizedDtsOptions === false ? void 0 : normalizedDtsOptions.generateTypes);

context: compiler.context,
outputDir: path3.relative(compiler.context, compiler.outputPath || compiler.options.output.path),
outputDir: getCompilerOutputDir(compiler),
moduleFederationConfig: __spreadValues({}, this._options),

@@ -250,9 +269,11 @@ hostRemoteTypesFolder: normalizedGenerateTypes.typesFolder || "@mf-types"

}
this._devWorker = createDevWorker({
name,
remote,
host,
extraOptions,
disableLiveReload: normalizedDev.disableHotTypesReload,
disableHotTypesReload: normalizedDev.disableHotTypesReload
this.fetchTypesPromise.then(() => {
this._devWorker = createDevWorker({
name,
remote,
host,
extraOptions,
disableLiveReload: normalizedDev.disableHotTypesReload,
disableHotTypesReload: normalizedDev.disableHotTypesReload
});
});

@@ -267,3 +288,3 @@ this._stopWhenSIGTERMOrSIGINT();

// packages/dts-plugin/src/plugins/TypesPlugin.ts
// packages/dts-plugin/src/plugins/DtsPlugin.ts
import { normalizeOptions as normalizeOptions4 } from "@module-federation/sdk";

@@ -274,14 +295,21 @@

var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
constructor(pluginOptions, dtsOptions, defaultOptions) {
constructor(pluginOptions, dtsOptions, defaultOptions, callback) {
__publicField(this, "pluginOptions");
__publicField(this, "dtsOptions");
__publicField(this, "defaultOptions");
__publicField(this, "callback");
this.pluginOptions = pluginOptions;
this.dtsOptions = dtsOptions;
this.defaultOptions = defaultOptions;
this.callback = callback;
}
apply(compiler) {
const { dtsOptions, defaultOptions, pluginOptions } = this;
const { dtsOptions, defaultOptions, pluginOptions, callback } = this;
if (isPrd()) {
callback();
return;
}
const normalizedConsumeTypes = normalizeOptions2(true, defaultOptions, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
if (!normalizedConsumeTypes) {
callback();
return;

@@ -295,6 +323,11 @@ }

}, normalizedConsumeTypes),
extraOptions: dtsOptions.extraOptions || {}
extraOptions: dtsOptions.extraOptions || {},
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
};
validateOptions(finalOptions.host);
consumeTypes(finalOptions);
consumeTypes(finalOptions).then(() => {
callback();
}).catch(() => {
callback();
});
}

@@ -307,17 +340,22 @@ };

import fs2 from "fs";
import path5 from "path";
import { normalizeOptions as normalizeOptions3 } from "@module-federation/sdk";
import path4 from "path";
var _GenerateTypesPlugin = class _GenerateTypesPlugin {
constructor(pluginOptions, dtsOptions, defaultOptions) {
constructor(pluginOptions, dtsOptions, defaultOptions, consumeTypesPromise, callback) {
__publicField(this, "pluginOptions");
__publicField(this, "dtsOptions");
__publicField(this, "defaultOptions");
__publicField(this, "consumeTypesPromise");
__publicField(this, "callback");
this.pluginOptions = pluginOptions;
this.dtsOptions = dtsOptions;
this.defaultOptions = defaultOptions;
this.consumeTypesPromise = consumeTypesPromise;
this.callback = callback;
}
apply(compiler) {
const { dtsOptions, defaultOptions, pluginOptions } = this;
const { dtsOptions, defaultOptions, pluginOptions, consumeTypesPromise, callback } = this;
const normalizedGenerateTypes = normalizeOptions3(true, defaultOptions, "mfOptions.dts.generateTypes")(dtsOptions.generateTypes);
if (!normalizedGenerateTypes) {
callback();
return;

@@ -329,6 +367,7 @@ }

context: compiler.context,
outputDir: path4.relative(compiler.context, compiler.outputPath || compiler.options.output.path),
outputDir: getCompilerOutputDir(compiler),
moduleFederationConfig: pluginOptions
}, normalizedGenerateTypes),
extraOptions: dtsOptions.extraOptions || {}
extraOptions: dtsOptions.extraOptions || {},
displayErrorInTerminal: dtsOptions.displayErrorInTerminal
};

@@ -354,58 +393,2 @@ if (dtsOptions.tsConfigPath && !finalOptions.remote.tsConfigPath) {

let compiledOnce = false;
const emitTypesFilesDev = /* @__PURE__ */ __name(() => __async(this, null, function* () {
try {
if (!isDev()) {
return;
}
const { zipTypesPath, apiTypesPath, zipName, apiFileName } = retrieveTypesAssetsInfo(finalOptions.remote);
yield generateTypesFn(finalOptions);
const config = finalOptions.remote.moduleFederationConfig;
let zipPrefix = "";
if (typeof config.manifest === "object" && config.manifest.filePath) {
zipPrefix = config.manifest.filePath;
} else if (typeof config.manifest === "object" && config.manifest.fileName) {
zipPrefix = path4.dirname(config.manifest.fileName);
} else if (config.filename) {
zipPrefix = path4.dirname(config.filename);
}
if (zipTypesPath) {
const zipContent = fs2.readFileSync(zipTypesPath);
const zipOutputPath = path4.join(compiler.outputPath, zipPrefix, zipName);
yield new Promise((resolve2, reject) => {
compiler.outputFileSystem.mkdir(path4.dirname(zipOutputPath), (err) => {
if (err)
reject(err);
else {
compiler.outputFileSystem.writeFile(zipOutputPath, zipContent, (writeErr) => {
if (writeErr)
reject(writeErr);
else
resolve2();
});
}
});
});
}
if (apiTypesPath) {
const apiContent = fs2.readFileSync(apiTypesPath);
const apiOutputPath = path4.join(compiler.outputPath, zipPrefix, apiFileName);
yield new Promise((resolve2, reject) => {
compiler.outputFileSystem.mkdir(path4.dirname(apiOutputPath), (err) => {
if (err)
reject(err);
else {
compiler.outputFileSystem.writeFile(apiOutputPath, apiContent, (writeErr) => {
if (writeErr)
reject(writeErr);
else
resolve2();
});
}
});
});
}
} catch (err) {
console.error(err);
}
}), "emitTypesFilesDev");
compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {

@@ -419,2 +402,3 @@ compilation.hooks.processAssets.tapPromise({

}, () => __async(this, null, function* () {
yield consumeTypesPromise;
try {

@@ -425,3 +409,2 @@ if (pluginOptions.dev === false && compiledOnce) {

if (compiledOnce) {
emitTypesFilesDev();
return;

@@ -439,15 +422,21 @@ }

} else if (typeof config.manifest === "object" && config.manifest.fileName) {
zipPrefix = path4.dirname(config.manifest.fileName);
zipPrefix = path5.dirname(config.manifest.fileName);
} else if (config.filename) {
zipPrefix = path4.dirname(config.filename);
zipPrefix = path5.dirname(config.filename);
}
if (zipTypesPath) {
compilation.emitAsset(path4.join(zipPrefix, zipName), new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
const zipAssetName = path5.join(zipPrefix, zipName);
if (zipTypesPath && !compilation.getAsset(zipAssetName)) {
compilation.emitAsset(path5.join(zipPrefix, zipName), new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
}
if (apiTypesPath) {
compilation.emitAsset(path4.join(zipPrefix, apiFileName), new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
const apiAssetName = path5.join(zipPrefix, apiFileName);
if (apiTypesPath && !compilation.getAsset(apiAssetName)) {
compilation.emitAsset(path5.join(zipPrefix, apiFileName), new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
}
compiledOnce = true;
callback();
} catch (err) {
console.error("Error in mf:generateTypes processAssets hook:", err);
callback();
if (finalOptions.displayErrorInTerminal) {
console.error("Error in mf:generateTypes processAssets hook:", err);
}
}

@@ -461,5 +450,4 @@ }));

// packages/dts-plugin/src/plugins/TypesPlugin.ts
var _a;
var TypesPlugin = (_a = class {
// packages/dts-plugin/src/plugins/DtsPlugin.ts
var _DtsPlugin = class _DtsPlugin {
constructor(options) {

@@ -485,3 +473,4 @@ __publicField(this, "options");

consumeTypes: defaultConsumeTypes,
extraOptions: {}
extraOptions: {},
displayErrorInTerminal: true
}, "mfOptions.dts")(options.dts);

@@ -491,18 +480,14 @@ if (typeof normalizedDtsOptions !== "object") {

}
new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes).apply(compiler);
new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes).apply(compiler);
let consumeTypesPromiseResolve;
const consumeTypesPromise = new Promise((resolve2) => {
consumeTypesPromiseResolve = resolve2;
});
let generateTypesPromiseResolve;
const generateTypesPromise = new Promise((resolve2) => {
generateTypesPromiseResolve = resolve2;
});
new DevPlugin(options, normalizedDtsOptions, generateTypesPromise).apply(compiler);
new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes, consumeTypesPromise, generateTypesPromiseResolve).apply(compiler);
new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes, consumeTypesPromiseResolve).apply(compiler);
}
}, __name(_a, "TypesPlugin"), _a);
// packages/dts-plugin/src/plugins/DtsPlugin.ts
var _DtsPlugin = class _DtsPlugin {
constructor(options) {
__publicField(this, "options");
this.options = options;
}
apply(compiler) {
const { options } = this;
new DevPlugin(options).apply(compiler);
new TypesPlugin(options).apply(compiler);
}
};

@@ -509,0 +494,0 @@ __name(_DtsPlugin, "DtsPlugin");

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

import { D as DTSManagerOptions } from './DTSManagerOptions-92108ee8.js';
import { D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
import '@module-federation/sdk';

@@ -3,0 +3,0 @@

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

import { k as DtsWorkerOptions } from './DtsWorker-1bad6327.js';
import { k as DtsWorkerOptions } from './DtsWorker-484d9f4a.js';
import 'child_process';
import './DTSManagerOptions-92108ee8.js';
import './DTSManagerOptions-c74c59ed.js';
import '@module-federation/sdk';

@@ -5,0 +5,0 @@ import 'typescript';

@@ -0,3 +1,3 @@

import { moduleFederationPlugin } from '@module-federation/sdk';
import { WebpackPluginInstance, Compiler } from 'webpack';
import { moduleFederationPlugin } from '@module-federation/sdk';

@@ -4,0 +4,0 @@ declare class DtsPlugin implements WebpackPluginInstance {

{
"name": "@module-federation/dts-plugin",
"version": "0.8.8",
"version": "0.8.9",
"author": "hanric <hanric.zhang@gmail.com>",

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

{
"name": "@module-federation/dts-plugin",
"version": "0.8.8",
"version": "0.8.9",
"author": "hanric <hanric.zhang@gmail.com>",

@@ -63,6 +63,6 @@ "main": "./dist/index.js",

"ws": "8.18.0",
"@module-federation/sdk": "0.8.8",
"@module-federation/managers": "0.8.8",
"@module-federation/third-party-dts-extractor": "0.8.8",
"@module-federation/error-codes": "0.8.8"
"@module-federation/sdk": "0.8.9",
"@module-federation/managers": "0.8.9",
"@module-federation/third-party-dts-extractor": "0.8.9",
"@module-federation/error-codes": "0.8.9"
},

@@ -76,3 +76,3 @@ "devDependencies": {

"vue-tsc": "^2.0.26",
"@module-federation/runtime": "0.8.8"
"@module-federation/runtime": "0.8.9"
},

@@ -79,0 +79,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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