Skip to content

Conversation

@aspiers
Copy link
Contributor

@aspiers aspiers commented Jan 18, 2024

The readme.md says that the following works:

import {isContentScriptRegistered} from 'webext-dynamic-content-scripts/utils.js';

if (await isContentScriptRegistered('https://google.com/search')) {
    console.log('Either way, the content scripts are registered');
}

However the import fails, because the exports section in package.json doesn't export utils.js. So add an entry to export it, thereby making the docs correct without needing to change them.

We don't add a wildcard entry to the exports section, because the intention is to explicitly export certain files, and hide the rest as internals.

It's also worth noting that the main file has side effects, so utils.js is exported separately for the benefit of consumers who need that but don't want the side effects.

Fixes #67.

The readme.md says that the following works:

    import {isContentScriptRegistered} from 'webext-dynamic-content-scripts/utils.js';

    if (await isContentScriptRegistered('https://google.com/search')) {
        console.log('Either way, the content scripts are registered');
    }

However the import fails, because the "exports" section in package.json
doesn't export utils.js.  So add an entry to export it, thereby making
the docs correct without needing to change them.

We don't add a wildcard entry to the "exports" section, because the
intention is to explicitly export certain files, and hide the rest as
internals.

It's also worth noting that the main file has side effects, so
utils.js is exported separately for the benefit of consumers who need
that but don't want the side effects.

Fixes fregante#67.
@fregante fregante changed the title Export utils.js for access to isContentScriptRegistered() (#67) Allow importing utils.js in newer Node tools Jan 18, 2024
@fregante fregante merged commit 85e56bf into fregante:main Jan 18, 2024
@fregante
Copy link
Owner

Thank you @aspiers! Releasing now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import from 'webext-dynamic-content-scripts/utils.js' doesn't work

2 participants