-
Notifications
You must be signed in to change notification settings - Fork 126
Unexpected token parsing package.json #28
Comments
That's incredibly weird. Is echo "var pkg = $(cat /home/falconerd/Projects/rollup-test3/node_modules/axios/package.json); console.log(pkg.name)" | node |
Hi Rich, the result of that command is Here's a gist of the package.json https://gist.github.com/Falconerd/13ad1f83c70a37850149 |
Ah, I wonder if the problem is that Rollup expects JavaScript instead of JSON. Could you try adding the rollup-plugin-json plugin? (Shouldn't matter which order it goes in). Also, it looks like axios has a So your config file should probably look like something along these lines: import { rollup } from 'rollup';
import commonjs from 'rollup-plugin-commonjs';
import npm from 'rollup-plugin-npm';
import json from 'rollup-plugin-json';
export default {
entry: 'index.js',
dest: 'bundle.js',
plugins: [
npm({
jsnext: true,
main: true,
browser: true
}),
commonjs({
include: 'node_modules/**'
}),
json()
],
format: 'iife'
}; |
Yep, that works. Thanks, @Rich-Harris.
|
HI~ I followed your instruction, but I met another problem. In my browser, it says [!] Error: Could not load http (imported by /Users/hehe/Sites/node_demo/my-svelte-project/demo_coupon/node_modules/axios/lib/adapters/http.js): ENOENT: no such file or directory, open 'http' It seems rollup use node version of axios not browser version. Is there anything wrong with my config?
|
Importing axios was causing problems until I figured out why at rollup/rollup-plugin-commonjs#28
Hi, I feel as if i'm missing something really obvious. I really want to adopt rollup. However, I'd like to be able to bundle for the browser as well - which I'm pretty sure this library does. Anyhow, I'll share my setup and the error I'm getting. If you could point me in the right direction that'd be awesome. Cheers!
rollup -c
The text was updated successfully, but these errors were encountered: