localnerve / csp-hashes

Flexible build library to generate script and style hashes for CSP headers or Meta tags

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import with CommonJS

Mathie01 opened this issue · comments

Hi !

Thank you for this library.
It's possible to import the library in CommonJS ?

Thanks!

Yes, the output is transpiled to interoperate. Here's how to use plain old require:

const hashstream = require('@localnerve/csp-hashes').default;

or

const { default: hashstream } = require('@localnerve/csp-hashes');

FUTURE NOTE:
To use 2.0.0+ package version without ESM, you must use dynamic import:

import('@localnerve/csp-hashes')
.then(({ default: hashstream }) => {
  hashstream({
    // options
  });
});