Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Unexpected Token #6

Closed
0x4d6165 opened this issue Apr 10, 2016 · 2 comments
Closed

Unexpected Token #6

0x4d6165 opened this issue Apr 10, 2016 · 2 comments

Comments

@0x4d6165
Copy link

Upon running the rollup config:

import babel from 'rollup-plugin-babel';
import json from 'rollup-plugin-json';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

export default {
  entry: 'server/server.js',
  format: 'umd',
  dest: 'bundelIndex.js',
  external: ['bluebird', 'knex', 'node-gyp', 'fsevents'],
  plugins: [
    babel({
      exclude: 'node_modules/**',
      babelrc: false,
      presets: ['react', 'es2015-rollup', 'stage-0'],
      plugins: ['transform-decorators-legacy'],
    }),
    json(),
    nodeResolve({ jsnext: true, main: true}),
    commonjs(),
  ],
};

I get the following error at runtime:

/Users/gigavinyl/Projects/ceres/server/assets.json: Unexpected token (1:5)
SyntaxError: /Users/gigavinyl/Projects/ceres/server/assets.json: Unexpected token (1:5)
{"js":"bundle.79f6da3830e25bcf5a6a.min.js"}

This appears to conform to the usage demonstrated in the README, what am I doing wrong here? Or is this an actual bug perhaps?

@jonataswalker
Copy link
Contributor

@gigavinyl See rollup/rollup-plugin-babel#48 (comment)

@Rich-Harris
Copy link
Contributor

Rich-Harris commented Dec 15, 2016

What @jonataswalker said – you could either run json before babel (recommended) or exclude .json files in the Babel config. I think the Babel plugin should also default to only including valid extensions as per #8

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

No branches or pull requests

3 participants