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

babel-plugin-injectcomponentcode

v2.0.2

Published

babel plugin react nextjs inject code

Downloads

259

Readme

babel-plugin-injectcomponentcode

Installation

npm i babel-plugin-injectcomponentcode

Usage

const babelPluginInjectComponentCode = require('babel-plugin-injectcomponentcode');

// babel.config.js
// 在 react 框架中 指定 jsx文件 进行 高阶组件行为
// 使用 glob 模式匹配

// options 配置 
// importComponentFilePath -> import 组件的 file path
// importComponentName -> import 组件的 name
// isImportDefault(可选参数) ->  是否默认导出(默认是 true)
// globMatchPath -> 需要被包裹的组件的相对路径 (参数规则同 glob)
// globIgnorePath -> 需要被忽略的组件的相对路径, 不会匹配 node_modules (参数规则同 glob)

// 如果没有传递 globMatchPath 和 globIgnorePath, 则会 只匹配 "/page.tsx" | "/page.jsx" 结尾的文件
module.exports = {
    ...
    plugins: [
        ...
        [[
            babelPluginInjectComponentCode, { 
                importComponentFilePath: '@/components/PageWrapper', 
                importComponentName: 'PageWrapper',
                isImportDefault: true, 
                globIgnorePath: "src/page/Home/index.tsx",
                globMatchPath: ["src/modules/KycRadioGroup/**/*.tsx"], // "src/page/**/*.tsx"
            }
        ]]
    ]
}

Example

In

import xx from 'xx'
const Demo = () => {

}
export default Demo

Out

import PageWrapper from '@/components/PageWrapper'
import xx from 'xx'
const Demo = () => {

}
export default PageWrapper(Demo)