🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

babel-plugin-injectcomponentcode

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-injectcomponentcode

babel plugin react nextjs inject code

Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
51
-58.2%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-injectcomponentcode

Installation

npm i babel-plugin-injectcomponentcode

Usage

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

// babel.config.js
// 在 next | react 框架中 指定 jsx文件 进行 高阶组件行为

// options 配置 
// importComponentFilePath -> import 组件的 file path
// importComponentName -> import 组件的 name
// isImportDefault(可选参数) ->  是否默认导出(默认是 true)
// needWrapperFileRelativePath(可选参数) -> 需要被包裹的组件的相对路径

module.exports = {
    ...
    plugins: [
        ...
        [[
            injectcomponentcode, { 
                importComponentFilePath: '@/components/PageWrapper', 
                importComponentName: 'PageWrapper',
                isImportDefault: true, 
            }
        ]]
    ]
}

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)

Keywords

babel

FAQs

Package last updated on 05 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts