richtr / NoSleep.js

Prevent display sleep and enable wake lock in any Android or iOS web browser.
MIT License
2.19k stars 379 forks source link

added ES6 importable version to dist #119

Open rjcortese opened 3 years ago

rjcortese commented 3 years ago

This PR contains a:

Motivation / Use-Case

Wanted to be able to use this project by importing an ES6 module like: import { NoSleep } from './nosleep.js';

This does just that. A user can copy the two files in dist/ES6 and then import in another module.

Breaking Changes

Additional Info

No breaking changes as it is... but it isn't integrated well with other parts of the package... basically have two versions of src. There has gotta be a better way... could use some input from the maintainer as to how to structure it. Might also be what #84 looks to fix.

richtr commented 3 years ago

Does the following not work for you?

import NoSleep from 'nosleep.js'

I’m not sure what the specific use case is to import this from a relative path.

rjcortese commented 3 years ago

It did not work for me. I believe all of that involves using Node runtime or a bundler or other module systems. See the note in this section: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#importing_features_into_your_script

I'm just wanting to use the ES6 browser based import mechanism.