@mappable-world/mappable-cli
Advanced tools
Comparing version 0.0.4 to 0.0.6
@@ -47,3 +47,4 @@ #!/usr/bin/env node | ||
PACKAGE_VERSION: '0.0.1-beta.1', | ||
PACKAGE_NAME: packageName | ||
PACKAGE_NAME: packageName, | ||
PACKAGE_NAME_ENC: encodeURIComponent(packageName), | ||
}; | ||
@@ -50,0 +51,0 @@ copyTemplateFiles(TEMPLATE_DIR, TARGET, true, macros); |
{ | ||
"name": "@mappable-world/mappable-cli", | ||
"version": "0.0.4", | ||
"version": "0.0.6", | ||
"description": "Library for encapsulating the logic of autotests and building packages mappable.world js API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,3 +7,3 @@ # %PACKAGE_NAME% package | ||
[![npm version](https://badge.fury.io/js/%PACKAGE_NAME%.svg)](https://badge.fury.io/js/%PACKAGE_NAME%) | ||
[![npm version](https://badge.fury.io/js/%PACKAGE_NAME_ENC%.svg)](https://badge.fury.io/js/%PACKAGE_NAME%) | ||
[![npm](https://img.shields.io/npm/dm/%PACKAGE_NAME%.svg)](https://www.npmjs.com/package/%PACKAGE_NAME%) | ||
@@ -19,18 +19,41 @@ | ||
to use Mappable JS Module you need to add your module loading handler to JS API | ||
Recommended use `MMapEntityTileLoader` as usual npm package: | ||
```sh | ||
npm i %PACKAGE_NAME% | ||
``` | ||
and dynamic import | ||
```js | ||
const {MMapEntityTileLoader} = await import('%PACKAGE_NAME%/dist/esm/index'); | ||
``` | ||
But you can use CDN with module loading handler in JS API: | ||
### Development | ||
```js | ||
mappable.import.loaders.unshift(async (pkg) => { | ||
if (!pkg.includes('%PACKAGE_NAME%')) { | ||
if (!pkg.startsWith('%PACKAGE_NAME%')) { | ||
return; | ||
} | ||
if (location.href.includes('localhost')) { | ||
await mappable.import.script(`/dist/index.js`); | ||
} else { | ||
// You can use another CDN | ||
await mappable.import.script(`https://unpkg.com/${pkg}/dist/index.js`); | ||
await mappable.import.script(`./node_modules/%PACKAGE_NAME%/dist/index.js`); | ||
return window[`${pkg}`]; | ||
}); | ||
``` | ||
### Production | ||
```js | ||
mappable.import.loaders.unshift(async (pkg) => { | ||
if (!pkg.includes('%PACKAGE_NAME%')) { | ||
return; | ||
} | ||
Object.assign(mappable, window[`${pkg}`]); | ||
// You can use another CDN | ||
await mappable.import.script(`https://unpkg.com/${pkg}/dist/index.js`); | ||
return window[`${pkg}`]; | ||
@@ -37,0 +60,0 @@ }); |
@@ -24,2 +24,9 @@ const path = require('path'); | ||
} | ||
}, | ||
'index.umd': { | ||
import: './src/index.ts', | ||
library: { | ||
name, | ||
type: 'umd' | ||
} | ||
} | ||
@@ -26,0 +33,0 @@ }, |
43820
668