New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

es-dev-commonjs-transformer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-dev-commonjs-transformer

CommonJS Module transformer for the es-dev-server

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
53
decreased by-36.14%
Maintainers
1
Weekly downloads
 
Created
Source

es-dev-commonjs-transformer

npm version

CommonJS Module transformer for the es-dev-server. It converts modules cjs -> esm format. Uses Rollup commonjs plugin under the hood.

// In
const a = require('dep');
...
module.exports = a;
// Out
import a from 'dep';
...
export default a;

General Usage

//es-dev-server.config.js

import cjsTransformer from 'es-dev-commonjs-transformer';

module.exports = {
    responseTransformers: [
        cjsTransformer(/* Exclude Paths Array */ [
            '**/node_modules/@open-wc/**/*',
            ...
        ])
    ]
}

OpenWC Karma Testing Setup

The Open-wc karma setup requires you to exlude some paths from being processed by the cjs transformer. The following excludes seems to have worked for me.

//karma.conf.ts

const cjsTransformer = require('es-dev-commonjs-transformer');
const { createDefaultConfig } = require('@open-wc/testing-karma');

module.exports = config => {
    let defaultConfig = createDefaultConfig(config);
    
    ...
    
    esm: {
        responseTransformers: [
        cjsTransformer([
                ...defaultConfig.esm.babelModernExclude,
                '**/node_modules/@open-wc/**/*',
                '**/node_modules/chai-dom/**/*',
                '**/node_modules/sinon-chai/**/*'
            ])
        ]
    }
}

Keywords

FAQs

Package last updated on 15 Jun 2020

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