I work on two Node packages at once, I will call them the Library and the Consumer. The library is responsible for providing a bunch of things in the browser. All users are import Library from 'library'
and call Library(someConfigHere)
- this is basically just a test to make sure the library does what I expect in the browser.
I have npm link
ed Library in Consumer and I try to launch Browserify on Consumer, but I get this error: ParseError: 'import' and 'export' may appear only with 'sourceType: module'
. The library does indeed contain the ES6 export
statement, so I assume that Browserify only works with Consumer, not the library.
So my question is: is there a way to get Browserify to also convert dependencies ?
This is my package.json
:
{ "name": "consumer", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "budo index.js --port $PORT", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "devDependencies": { "babel-preset-es2015": "^6.13.2", "babel-preset-react": "^6.11.1", "babelify": "^7.3.0", "browserify-shim": "^3.8.12" }, "browserify": { "transform": [ "babelify" ] }, "babel": { "presets": [ "es2015", "react" ] } }
This is consumer index.js
:
import Library from 'library' // <= this is what isn't getting babelified console.log(Library);
This is the index.js
library:
export default (config) => { console.log('Testing testing') }