@mappable-world/mappable-cli
Advanced tools
Comparing version 0.0.24 to 0.0.25
{ | ||
"name": "@mappable-world/mappable-cli", | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"description": "Library for encapsulating the logic of autotests and building packages mappable.world js API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -30,2 +30,19 @@ # Contributing | ||
## Development loader | ||
For development, you shold load from `dist`: | ||
```js | ||
mappable.import.loaders.unshift(async (pkg) => { | ||
if (!pkg.startsWith('%PACKAGE_NAME%')) return; | ||
// Load script from dev server | ||
await mappable.import.script(`./dist/index.js`); | ||
return window['%PACKAGE_NAME%']; | ||
}); | ||
``` | ||
## GitHub actions | ||
@@ -32,0 +49,0 @@ |
@@ -19,3 +19,3 @@ # %PACKAGE_NAME% package | ||
Recommended use `MMapEntityTileLoader` as usual npm package: | ||
Recommended use `MMapButtonExample` as usual npm package: | ||
@@ -29,40 +29,38 @@ ```sh | ||
```js | ||
const {MMapEntityTileLoader} = await import('%PACKAGE_NAME%/dist/esm/index'); | ||
await mappable.ready; | ||
// ... | ||
const {MMapButtonExample} = await import('%PACKAGE_NAME%'); | ||
// ... | ||
map.addChild(new MMapButtonExample(props)); | ||
``` | ||
But you can use CDN with module loading handler in JS API: | ||
### Usage without npm | ||
### Development | ||
You can use CDN with module loading handler in JS API on your page. | ||
Just use `mappable.import`: | ||
```js | ||
mappable.import.loaders.unshift(async (pkg) => { | ||
if (!pkg.startsWith('%PACKAGE_NAME%')) { | ||
return; | ||
} | ||
await mappable.import.script(`./node_modules/%PACKAGE_NAME%/dist/index.js`); | ||
return window['%PACKAGE_NAME%']; | ||
}); | ||
const pkg = await mappable.import('%PACKAGE_NAME%') | ||
``` | ||
### Production | ||
By default `mappable.import` can load self modules. | ||
If you want also load your package, should add `loader`: | ||
```js | ||
// Add loader at start loaders array | ||
mappable.import.loaders.unshift(async (pkg) => { | ||
if (!pkg.includes('%PACKAGE_NAME%')) { | ||
return; | ||
} | ||
// Process only your package | ||
if (!pkg.includes('%PACKAGE_NAME%')) return; | ||
// You can use another CDN | ||
await mappable.import.script(`https://unpkg.com/${pkg}/dist/index.js`); | ||
// Load script directly. You can use another CDN | ||
await mappable.import.script(`https://unpkg.com/${pkg}/dist/index.js`); | ||
return window[`${pkg}`]; | ||
// Return result object | ||
return window['%PACKAGE_NAME%']; | ||
}); | ||
``` | ||
and in your final code just use `mappable.import` | ||
```js | ||
const pkg = await mappable.import('%PACKAGE_NAME%') | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58101