Instabug-React-Native
Instabug-React-Native copied to clipboard
Can you include compiled/transpiled (from ES6) code in the npm package?
Our test environment runs our compiled/transpiled code, not the source code.
When I include Instabug in a module that is under test, I see this error:
SyntaxError: Cannot use import statement outside a module
I think this is because your package.json's main
points to index.js
which is the original code.
Is it possible for you to transpile the code and point the main
to a directory that includes the transpiled code instead?
SDK Version
8.7.3
@nchase, thanks for the report, we're looking into the issue and if we should transpile the code.
In the meantime, would your issue be solved by excluding Instabug from the module being tested?
@nchase Usually you would want to exclude Instabug as a module from your tests, you can do so in your testing framework, in Jest for example you can use the property transformIgnorePatterns
in your package.json to exclude Instabug, more info here
Hi Instabug team – We can exclude it manually the way you've described, but since you are a providing a dependency, I think other users will run into this and you may see more of these similar issues as your userbase grows.
Having taken a look at a handful of the other dependencies that we use, all of the dependencies that write their source code as something other than standard ES5 point their main
at a transpiled ES5 version of the source code.
We can work around this for now, but I think providing transpiled code (at least in the version of the module that gets distributed to NPM) is something that you should consider.
We can work around this for now, but I think providing transpiled code (at least in the version of the module that gets distributed to NPM) is something that you should consider.
What you're saying makes sense. We will be working on that for a future release.
I'll keep this issue open for further discussion related to this till we release it.
My apology for this taking longer than it should.
Our package now include ESNext transpiled code after migrating to TS in #783. Hope this fix your issue (if it still exists after 3 years), and always feel free to re-open if the issue still exists.