Skip to content

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

@aspiers

Description

@aspiers

The README says that this should work:

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

However, it refuses to import:

[commonjs--resolver] Missing "./utils.js" export in "webext-dynamic-content-scripts" package

As far as I can tell, this is due to the "exports" section of package.json not covering this file:

"exports": {
".": {
"types": "./distribution/index.d.ts",
"default": "./distribution/index.js"
},
"./including-active-tab.js": {
"types": "./distribution/including-active-tab.d.ts",
"default": "./distribution/including-active-tab.js"
}
},

I tried adding these lines to this section:

		"./utils.js": {
			"types": "./distribution/utils.d.ts",
			"default": "./distribution/utils.js"
		}

and then the import immediately worked.

I'm no Javascript expert, but it seems a bit odd to be declaring each of these files manually in "exports". Can't it be done with a wildcard? And is there any reason not to re-export isContentScriptRegistered from index.ts, so that it can be imported directly from 'webext-dynamic-content-scripts'?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions