Skip to content

environment-safe/package

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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';
(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

About

local package.json support using import or require in node and the browser, no build required

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 59.5%
  • HTML 34.2%
  • Dockerfile 4.1%
  • Shell 2.2%