Coder Social home page Coder Social logo

es6-module-loader's Introduction

ES6-Module-Loader

Supports Circular Dependencies

// Rock.js
import * as ScissorModule from 'Scissor.js'

export default class Rock {
  isStrongerThan(other) {
    return other instanceof ScissorModule.default
  }
}

// Scissor.js
import * as PaperModule from 'Paper.js'

export default class Scissor {
  isStrongerThan(other) {
    return other instanceof PaperModule.default
  }
}

// Paper.js
import * as RockModule from 'Rock.js'

export default class Paper {
  isStrongerThan(other) {
    return other instanceof RockModule.default
  }
}

Entry module:

import Rock from 'Rock.js'
import Scissor from 'Scissor.js'
import Paper from 'Paper.js'

let a = new Rock()
let b = new Scissor()
let c = new Paper()

console.log(a.isStrongerThan(b))
console.log(a.isStrongerThan(c))

console.log(b.isStrongerThan(a))
console.log(b.isStrongerThan(c))

console.log(c.isStrongerThan(a))
console.log(c.isStrongerThan(b))
<!-- include import.js -->
<script src="import.js"></script>
<!-- use in scripts -->
<script>
  System.import('./entry.js')
</script>

Import standard JS interface as modules

import { PI, sqrt, abs } from 'std/math'
import { create as createObject } from 'std/object'

console.log(sqrt(2), PI)
console.log(createObject(null))

es6-module-loader's People

Contributors

bumfo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.