0.0.4 • Published 10 months ago

environment-safe-package v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

environment-safe-package

This normalizes the difference for local inclusion of package.json whether in node or the browser with no build.

Babel will merrily pass this through, while browsers won't. If you want source execution in both environments without build, there is no option. That's where this comes in.

Usage

Using modules

import { getPackage } from 'environment-safe-package/src/environment-safe-package.mjs';
(async ()=>{
    const package = await getPackage();
    //do something with the package here
})()

Using commonjs

const { getPackage } = require('environment-safe-package');
(async ()=>{
    const package = await getPackage();
    //do something with the package here
})();

Testing

Run the es module tests to test the root modules

npm run import-test

to run the same test inside the browser:

npm run browser-test

to run the same test headless in chrome:

npm run headless-browser-test

to run the same test inside docker:

npm run container-test

Development

All work is done in the .mjs files and will be transpiled on commit to commonjs and tested.

If the above tests pass, then attempt a commit which will generate .d.ts files alongside the src files and commonjs classes in dist

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago