New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/typescript

Package Overview
Dependencies
Maintainers
4
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/typescript - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

2

package.json
{
"name": "@module-federation/typescript",
"version": "0.2.1",
"version": "0.2.2",
"description": "Webpack plugin to stream typescript for module federation apps/components",

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

@@ -22,4 +22,4 @@ const ts = require("typescript");

const distPath =
get(this.options, "devServer.static.directory") ||
get(this.options, "output.path") ||
get(this.compilerOptions, "devServer.static.directory") ||
get(this.compilerOptions, "output.path") ||
"dist";

@@ -99,22 +99,44 @@

extractTypes() {
const normalizedFileNames = [];
getExtension(rootDir, entry) {
// Check path exists and it's a directory
if (!fs.existsSync(rootDir) || !fs.lstatSync(rootDir).isDirectory()) {
throw new Error('rootDir must be a directory');
}
const fileNames = Object.values(this.exposedComponents);
let filename;
fileNames.forEach((componentFilePath) => {
const ext = path.extname(componentFilePath);
try {
// Try to resolve exposed component using index
const files = fs.readdirSync(path.join(rootDir, entry));
// TODO: Resolve the file ext automatically if not provided in the ModuleFederation Config
if ([".ts", ".tsx"].includes(ext)) {
const normalizedPath = path.resolve(process.cwd(), componentFilePath);
filename = files.find(file => file.split('.')[0] === 'index');
normalizedFileNames.push(normalizedPath);
} else {
throw new Error(
`Can not determine file extension, please include file extension for the file ${componentFilePath}`
);
}
});
return `${entry}/${filename}`;
}
catch (err) {
const files = fs.readdirSync(rootDir);
// Handle case where directory contains similar filenames
// or where a filename like `Component.base.tsx` is used
filename = files.find(file => {
const baseFile = path.basename(file, path.extname(file));
const baseEntry = path.basename(entry, path.extname(entry));
return baseFile === baseEntry;
});
return filename;
}
}
extractTypes() {
const normalizedFileNames = Object.values(this.exposedComponents)
.map(exposed => {
const [ rootDir, entry ] = exposed.split(/\/(?=[^/]+$)/);
const ext = this.getExtension(rootDir, entry);
return path.resolve(process.cwd(), rootDir, ext);
})
.filter(entry => /\.tsx?$/.test(entry));
const host = ts.createCompilerHost(this.tsCompilerOptions);

@@ -121,0 +143,0 @@ const originalWriteFileFn = host.writeFile;

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