Continued problems with issue #103 ('import' and 'export' may appear only with 'sourceType: module')
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
Hello. This is a follow up to an existing (but closed) issue (#103). I am having the same issue. I've tried the suggestions in #103, but still cannot resolve the issue (see below). Are the solutions in that issue still relevant, or have they become obsolete?
In my case, the Browserify command is:
`node_modules/.bin/browserify www/js/functions.js test/tape.test.js -t [ babelify ] --outfile test/test-bundle.js`
It is failing with the error:
`SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (4819:0) while parsing C:\Users\snarl\Orbis\osatest\node_modules\fetch-mock\esm\client.js while parsing file: C:\Users\snarl\Orbis\osatest\node_modules\fetch-mock\esm\client.js`
___
**My Attempts To Resolve**
--From #103, I tried installing the package `babel-preset-es2015` then running the command:
`node_modules/.bin/browserify www/js/functions.js test/tape.test.js -t [ babelify --presets [ es2015 ] ] --outfile test/test-bundle.js`
The previous error was gone, but it failed with a new error:
`Error: Plugin/Preset files are not allowed to export objects, only functions. In C:\Users\snarl\Orbis\osatest\node_modules\babel-preset-es2015\lib\index.js while parsing file: C:\Users\snarl\Orbis\osatest\test\tape.test.js`
A few Stack Overflow posts ([example](https://stackoverflow.com/questions/57404787/babel-loader-error-plugin-preset-files-are-not-allowed-to-export-objects-only-f)) seemed to indicate that this was because I was using `babel-preset-es2015`, and had to eschew it in favor of a different package; `@babel/preset-env ` I've removed the old package, and installed the new package. But the Browserify command is back to failing with the original import/export error.
--With `@babel/preset-env` installed, I tried three different configurations in my project's `babel.config.js` file ([see pastebin here](https://pastebin.com/)), but none had any effect on the issue. Those suggestions were taken from the [@babel/preset-env page](https://babeljs.io/docs/en/babel-preset-env ).
--With `@babel/preset-env` installed, I tried using the following command from the command line, but there was no change in the result.
`node_modules/.bin/browserify www/js/functions.js test/tape.test.js -t [ babelify --presets [ es2015 ] ] --outfile test/test-bundle.js`
--To see the code in each of my JS files, please see [this pastebin](https://pastebin.com/du8TseY1).
___
FYI I am using Browserify v16.5.1 and Babelify v10.0.0.
Thanks in advance.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.