-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,27 @@ yarn add runtime-memcache | |
|
||
## Usage | ||
|
||
```javascript | ||
const createStore = require('runtime-memcache').default; | ||
### Node Environment (ES6 import/export) | ||
|
||
// or using es6 imports | ||
```javascript | ||
import createStore from 'runtime-memcache'; | ||
``` | ||
|
||
### Node Environment (CJS) | ||
|
||
```javascript | ||
const createStore = require('runtime-memcache'); | ||
``` | ||
|
||
### Browser (use a script tag) | ||
|
||
```html | ||
<script src="https://unpkg.com/[email protected]/dist/umd/index.js"></script> | ||
<script> | ||
console.log(RMC()); | ||
</script> | ||
``` | ||
|
||
## API | ||
|
||
Calling the `createStore` function returns an object with the following properties. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist/cjs/", | ||
"module": "commonjs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
const path = require('path'); | ||
|
||
module.exports = (env, argv) => { | ||
return { | ||
entry: { | ||
index: path.resolve(__dirname, './dist/esm/index.js'), | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, './dist/umd'), // builds to ./dist/umd/ | ||
filename: '[name].js', // index.js | ||
library: 'myLibrary', // aka window.myLibrary | ||
libraryTarget: 'umd', // supports commonjs, amd and web browsers | ||
globalObject: 'this', | ||
libraryExport: 'default', | ||
}, | ||
module: { | ||
rules: [{ test: /\.t|js$/, use: 'babel-loader' }], | ||
}, | ||
}; | ||
const umd = { | ||
entry: { | ||
index: path.resolve(__dirname, './dist/cjs/index.js'), | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, './dist/umd'), // builds to ./dist/umd/ | ||
filename: '[name].js', // index.js | ||
library: 'RMC', // aka window.RMC | ||
libraryTarget: 'umd', // supports commonjs, amd and web browsers | ||
globalObject: 'this', | ||
libraryExport: 'default', | ||
}, | ||
module: { | ||
rules: [{ test: /\.t|js$/, use: 'babel-loader' }], | ||
}, | ||
}; | ||
|
||
module.exports = [umd]; |