Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maiermic opened this issue Jul 15, 2015 · 1 comment
Open

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

maiermic opened this issue Jul 15, 2015 · 1 comment

Comments

@maiermic
Copy link

I switched from 6to5ify@3.1.2 to babelify@6.1.3 and at the same time upgraded browserify from 6.3.4 to 10.2.6, watchify from 2.3.0 to 3.2.3 and remapify from 1.4.3 to 2.0.3. Now I get several build errors: 'import' and 'export' may appear only with 'sourceType: module'

My build file looks more or less like this:

const browserify = require('browserify');
const babelify = require('babelify');
const remapify = require('remapify');
const watchify = require('watchify');

const b = browserify({
  cache: {},
  packageCache: {},
  fullPaths: false,
  debug: true
});
b.add(myFile);
b.transform(babelify);
b.plugin(remapify, [...]);
watchify(b).bundle(function(err, buf) { ... });

This error does not appear with pathmodify instead of remapify (see).

@amakhrov
Copy link

amakhrov commented Jan 6, 2016

I've got somewhat similar with jadeify@^4.4.0 + remapify@^2.1.0 (using in grunt-browserify@~4.0.1 setup).
grunt-browserify config:

options: {
    plugin: [
        [
            'remapify',
            [{
                src: '**/*.*',  // glob for the files to remap
                expose: '',
                cwd: path.join(__dirname, 'media', 'source', 'scripts')
            }]
        ]
    ],

    transform: [
        ['jadeify', {
            compileDebug: debug,
            pretty: false
        }]
    ]
},

When I try to require .jade files using the mapped alias (e.g. lib/templates/template.jade) I'm getting an error:

>> __dir-name__/template.jade:1
>> .help
>> ^
>> ParseError: Unexpected token

However, without the mapping it works well - if I just specify the full relative path ('../../../../lib/templates/template.jade')

Switching to pathmodify seems to solve the issue, btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants