Skip to content

'import' and 'export' may appear only with 'sourceType: module' #11

@mnoble01

Description

@mnoble01

##I'm getting this error when using pathmodify.

What I'm trying to do is alias an underscore-extend for all calls to require('underscore') (or import 'underscore' in ES6). The reason for this is I'm mixing in some of my own functions to underscore and I'd like them to be available anywhere underscore is required in my codebase.

Here's my underscore-extend.js:

import _ from 'vendor/underscore'

_.mixin({
...
})

export default _

And my gulpfile:

 let b = browserify({
    entries: `./app/${app}/index.js`, 
    debug: true,
    detectGlobal: false,
    paths: [
      './app/shared/',
      './app/shared/lib/',
      './app/'
    ]
  }).transform(browserifyShim) // config must be in package.json
    .transform('babelify', {presets: ['es2015'], compact: false})
    .transform('brfs')
    .plugin(pathmodify, {mods: [
      pathmodify.mod.id('underscore', 'shared/lib/underscore-extend')
    ]})

I'm wondering if it's just the order of transforms/plugins or if the pathmodify plugin is wrongly parsing the erroring file in ES6 instead of from the stream. Or something else I'm not even thinking of.

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