This commit is contained in:
Philipp Kunz 2016-10-06 19:28:00 +02:00
commit ae5021b728
5 changed files with 109 additions and 0 deletions

53
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,53 @@
image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
- trigger
- page
testLEGACY:
stage: test
script:
- npmci test legacy
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
tags:
- docker
release:
stage: release
script:
- npmci publish
only:
- tags
tags:
- docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
pages:
image: hosttoday/ht-docker-node:npmpage
stage: page
script:
- npmci command npmpage --host gitlab
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public

37
README.md Normal file
View File

@ -0,0 +1,37 @@
# smartsystem
simplifies lazy loading with TypeScript
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartsystem)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartsystem)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartsystem)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartsystem/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartsystem/badges/master/build.svg)](https://gitlab.com/pushrocks/smartsystem/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartsystem/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartsystem/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartsystem.svg)](https://david-dm.org/pushrocks/smartsystem)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartsystem/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartsystem/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartsystem/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartsystem)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
We recommend the use of TypeScript for best Intellisense
```typescript
import {LazyModule, loadNow } from 'smartsystem'
import * as myPluginType from 'myPlugin' // plugin does not get loaded here at runtime
let myPluginPromised = LazyModule<typeof myPlugin>('myPlugin')
import * as anotherPluginType from 'anotherPlugin' // plugin does not get loaded here at runtime
let anotherPluginPromised = LazyModule<typeof anotherPlugin>('anotherPlugin')
myPluginPromised.then(myPlugin => { /* do something with myPlugin */ })
myPlugin.also(anotherPluginPromised).then((m,a) => {}) // also takes multiple other plugins
loadNow.only('myPlugin') // loads myPlugin and resolved the lazy promise
loadNow.also('myPlugin') // loads myPlugin and any chained 'also' modules
```

19
package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "smartsystem",
"version": "1.0.0",
"description": "wraps systemjs for smarter workflows",
"main": "dist/index.js",
"scripts": {
"test": "(npmts)"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/smartsystem.git"
},
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/smartsystem/issues"
},
"homepage": "https://gitlab.com/pushrocks/smartsystem#README"
}

0
ts/index.ts Normal file
View File

View File