Fix errors when importing Glean.js in Typescript environments #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently when attempting to import the @mozilla/glean package in the Bergamot extension, we get the following error:
I am mostly sure that the problem is with our types definitions. If you look at this thread , you'll notice that it is not ironed out exactly how
exports
and type declarations play together.I have used the
typesVersions
workaround since the change to useexports
, because I am basing myself off of howjose
does thigs.I seem to be using it incorrectly. In this branch I made some experiements. You'll see that I included conditional imports for different environment, after noticing that bergamot is expecting
commonjs
modules. That was not the issue, but since I've already done the work I decided to keep it (we had a bug for it anyways).Playing around with the
typesVersions
field was more promising. The way that is is right now I finally don't get an error when importing Glean in in the Bergamot extension 馃帀I also don't get an error when running
yarn run build:production
. Yay!Sadly the minute I use the imported
Glean
object, either throughGlean.initialize
or evenconsole.log(Glean)
I get back to the sameCannot find module...
.Also this only solves the
/webext
import, when attempting to do something like/webext/private/ping
for example, we get back to not being able to import.