Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@joblift/babel-plugin-transform-require-ignore

Package Overview
Dependencies
Maintainers
6
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@joblift/babel-plugin-transform-require-ignore

ignore the required file by extension type

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
0
-100%
Maintainers
6
Weekly downloads
 
Created
Source

babel-plugin-transform-require-ignore

This is a fork from https://github.com/morlay/babel-plugin-transform-require-ignore, which adds an option to exlude patterns.

Since https://nodejs.org/api/globals.html#globals_require_extensions deprecated.

We have to find another way to ignore the extensions for webpack usage and make it work in node environment.

Configure it in .babelrc for node, we could ignore the requirement when run test in node or build server render app.

Then we run babel with BABEL_ENV=node will active this plugin;

{
  "env": {
    "node": {
      "plugins": [
        [
          "babel-plugin-transform-require-ignore",
          {
            "extensions": [".less", ".sass"]
          }
        ]
      ]
    }
  }
}

or use with babel-register in require-hooks

require('babel-register')({
  'plugins': [
    [
      'babel-plugin-transform-require-ignore',
      {
        extensions: ['.scss']
      }
    ]
  ]
});

Or with cli like other plugin used.

Notice:

Only ignore import './some.less'; or require('./some.less');

If assign to some variable, means that may use css-module, please use https://github.com/css-modules/css-modules-require-hook instead.

Keywords

babel-plugin

FAQs

Package last updated on 10 May 2021

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