Coder Social home page Coder Social logo

js-module-formats's Introduction

Javascript Module Formats

Build Status Dependency Status npm Version

Microlibrary to detect different types of javascript modules formats from a javascript file.

Goals, Overview & Features

With the new ES Module syntax arrival, projects will comence the transition to write modules in ES format, and in some cases, rewrite/adjust modules to be ES module. As a result, complex applications might ended up having multiple module formats in their application, while the proper transpile process will be necessary. This microlibrary will help you to detect what type of module does a javascript file defines, and take the appropiate steps based on that information.

Installation

Install using npm:

$ npm install js-module-formats

Usage

By calling detect() with a filesystem path, it returns one of the following values:

  • yui Modules
  • amd Modules
  • cjs CommonJS modules (including nodejs modules)
  • es Modules
  • undefined if the detection fails

To detect the module format of a file called file.js:

var detect = require('js-module-formats').detect,

console.log(detect(__dirname + '/file.js'));

Note: ES modules without import or export statements will not be detected.

License

This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.

js-module-formats's People

Contributors

caridy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.