npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@efox/emp-tune-dts-plugin

v1.3.5

Published

Tune d.ts Plugin

Downloads

1,942

Readme

@efox/emp-tune-dts-plugin

Generate type files for Module Federation project

English | 简体中文

🧐 Why

  • In Typescript development, quoting remote project content requires type file support.
  • The module type generated by tsc is a relative path and cannot be used by remote projects.
  • Module Federation issues: How typesafe can a remote be with Typescript?

✨ Feature

  • Generate a d.ts file containing all types of the project
  • Type with current project name, not relative path
  • Form a closed loop of types, from generation to reference complete
  • Support custom modification

😊 Example

When there is no emp-tune-dts-plugin in this world

The type file generated by directly executing tsc -d is a relative path.

After pulling this type of file to the sub-project, the sub-project cannot recognize the type of the remote component, resulting in failure to compile successfully and type prompts.

When this world has emp-tune-dts-plugin

After executing yarn emp build --ts, a type file index.d.ts with the current project name as the path prefix will be generated.

Drag the type file generated by emp-tune-dts-plugin to the sub-project, the sub-project can not only recognize the type of the remote component, but also compile successfully and have type prompts. Reference to remote components, methods, etc. and hints, there is a feeling of service discovery on microservices.

👨‍🔧 Architecture

Architecture

📦 Quick start

npm i @efox/emp-tune-dts-plugin or yarn add @efox/emp-tune-dts-plugin

👨🏻‍💻 Use plugins on Webpack

const { TuneDtsPlugin } = require('@efox/emp-tune-dts-plugin')

Way 1 recommended

const createName = 'index.d.ts'
const createPath = './dist'
function operationDemo(fileData) {
  console.log(fileData)
  return fileData;
}
plugin.tunedts = {
  plugin: TuneDtsPlugin,
  args: [
      {
          output: path.join(createPath, createName),
          path: createPath,
          name: createName,
          isDefault:true,
          // Incoming function custom operation
          operation: operationDemo
        },
  ],
};

Way 2

function operationDemo(fileData) {
  console.log(fileData)
  return fileData;
}
plugins: [
    new TuneDtsPlugin({
          output: path.join(createPath, createName),
          path: createPath,
          name: createName,
          isDefault:true,
          // Incoming function custom operation
          operation: operationDemo
        })
]

Parameter explanation: | Parameter | Type | Explanation | | ---- | ---- | --- | | output| string (Required)| d.ts File output directory| | path| string (Required)| d.ts Folder path| | name| string (Required)| d.ts File name| | isDefault | boolean(Required) | Replace relative paths with absolute paths by default | | isRmExportDefault | boolean(Optional) | remove default = | | operation| Function (Optional)| Custom operation d.ts file function (when isDefault is true, operation will inherit the content after the default Replace). The input parameter is the content of the d.ts file, and the d.ts data must be returned after the operation is completed. operationDemo as an example|

💪 Generate

  • After connecting to the Webpack Plugin, run Webpack to generate the type file of the current Module Federation project and save it in dist

🔗 Remote reference

Way 1

yarn add @efox/emp-cli

yarn emp tss YourRemoteProjectAddress /index.d.ts -n YourRemoteProjectName.d.ts

Way 2

Use VSCode plugin: emp-sync-base