Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-nej-module

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-nej-module

transform nej module to require

  • 2.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-52.94%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-nej-module

使用webpack打包nej。通过本插件,可以将nej的依赖管理系统转换为标准AMD格式,使得webpack能够对它进行打包。

使用方法

  1. 安装:npm install --save-dev babel-plugin-transform-nej-module;
  2. 在babel-loader中使用本插件
{
    test: /\.js$/,
    exclude: /(node_modules|bower_components)/,
    use: {
        loader: 'babel-loader',
        options: {
            presets: [],
            plugins: ['babel-plugin-transform-nej-module']
        }
    }
},
  1. webpack.config.js中增加路径配置,根据nej所在位置、代码使用的别名进行调整;
{
    resolve: {
        alias: {
            'base': path.resolve(__dirname, 'lib/nej/src/base'),
            'platform': path.resolve(__dirname, 'lib/nej/src/base/platform')
        }
    }
}
  1. 引入额外的nej-polyfill

使用示例

webpack配置示例如下:

const path = require('path');
const resolve =path.resolve;

module.exports = {
    resolve: {
        alias: {
            'pro': path.resolve(__dirname, 'src/javascript'),
            'pool': path.resolve(__dirname, 'lib'),
            'base': path.resolve(__dirname, 'lib/nej/src/base'),
            'platform': path.resolve(__dirname, 'lib/nej/src/base/platform')
        }
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-es2015'],
                        plugins: ["transform-remove-strict-mode", 'babel-plugin-transform-nej-module']
                    }
                }
            },
            {
                test: /\.css$/,
                exclude: /(node_modules|bower_components)/,
                use: ['style-loader', 'css-loader']
            },
            {
                test: /\.(html)$/,
                use: {
                    loader: 'html-loader',
                    options: {
                        attrs: [':data-src']
                    }
                }
            }
        ]
    }
}

Keywords

FAQs

Package last updated on 29 Mar 2018

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

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