Skip to content

Commit

Permalink
feat(rollup): configure default options for rollup-node-resolve plugi…
Browse files Browse the repository at this point in the history
…n (browser and extensions) (#199)

The most important here is `browser: true`. 
Without that, Rollup will bundle for Node.js and so it will expect we run the bundle with Node.js, but that's not our case.

![selection_117](https://user-images.githubusercontent.com/2103975/51528607-50414480-1e37-11e9-83cf-39d1923fd168.png)
![selection_118](https://user-images.githubusercontent.com/2103975/51528610-520b0800-1e37-11e9-9ec5-01ae9f6848e1.png)
  • Loading branch information
Kocal authored Jan 22, 2019
1 parent 37bb71e commit 249a4b4
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
6 changes: 5 additions & 1 deletion lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export function defaults(): ProjectOptions {
handlers: {
sass: {},
rollup: {
nodeResolve: {}, // https://github.com/rollup/rollup-plugin-node-resolve
nodeResolve: {
module: true,
browser: true,
extensions: ['.mjs', '.js', '.json', '.node', '.vue'],
}, // https://github.com/rollup/rollup-plugin-node-resolve
commonjs: {}, // https://github.com/rollup/rollup-plugin-commonjs
json: {}, // https://github.com/rollup/rollup-plugin-json#usage
vue: {}, // https://rollup-plugin-vue.vuejs.org/options.html#options
Expand Down
2 changes: 1 addition & 1 deletion test/spec/__fixtures__/src/components/button/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue';
import Button from './Button.vue';
import Button from './Button';

Vue.component('y-button', Button);

Expand Down
48 changes: 44 additions & 4 deletions test/spec/api/__snapshots__/configuration.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,17 @@ Object {
"rollup": Object {
"commonjs": Object {},
"json": Object {},
"nodeResolve": Object {},
"nodeResolve": Object {
"browser": true,
"extensions": Array [
".mjs",
".js",
".json",
".node",
".vue",
],
"module": true,
},
"shims": Object {},
"vue": Object {},
},
Expand Down Expand Up @@ -125,7 +135,17 @@ Object {
"rollup": Object {
"commonjs": Object {},
"json": Object {},
"nodeResolve": Object {},
"nodeResolve": Object {
"browser": true,
"extensions": Array [
".mjs",
".js",
".json",
".node",
".vue",
],
"module": true,
},
"shims": Object {},
"vue": Object {},
},
Expand Down Expand Up @@ -221,7 +241,17 @@ Object {
"rollup": Object {
"commonjs": Object {},
"json": Object {},
"nodeResolve": Object {},
"nodeResolve": Object {
"browser": true,
"extensions": Array [
".mjs",
".js",
".json",
".node",
".vue",
],
"module": true,
},
"shims": Object {},
"vue": Object {},
},
Expand Down Expand Up @@ -274,7 +304,17 @@ Object {
"rollup": Object {
"commonjs": Object {},
"json": Object {},
"nodeResolve": Object {},
"nodeResolve": Object {
"browser": true,
"extensions": Array [
".mjs",
".js",
".json",
".node",
".vue",
],
"module": true,
},
"shims": Object {},
"vue": Object {},
},
Expand Down
4 changes: 2 additions & 2 deletions test/spec/api/commands/__snapshots__/build.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports[`command: build lint (and fix) before build should lint (and but fix) fi

exports[`command: build lint (and fix) before build should lint (and but fix) files built with handler \`rollup\`, before building them: button/index.js after lint 1`] = `
"import Vue from 'vue';
import Button from './Button.vue';
import Button from './Button';
Vue.component('y-button', Button);
Expand All @@ -36,7 +36,7 @@ console.log(\\"Hello from index.js!\\");

exports[`command: build lint (and fix) before build should lint (and but fix) files built with handler \`rollup\`, before building them: button/index.js before lint 1`] = `
"import Vue from 'vue';
import Button from './Button.vue';
import Button from './Button';
Vue.component('y-button', Button);
Expand Down
4 changes: 2 additions & 2 deletions test/spec/api/commands/__snapshots__/lint.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports[`command: build lint (and fix) should lint and fix JS entries only: js/b

exports[`command: build lint (and fix) should lint and fix Rollup entries only: button/index.js after lint 1`] = `
"import Vue from 'vue';
import Button from './Button.vue';
import Button from './Button';
Vue.component('y-button', Button);
Expand All @@ -36,7 +36,7 @@ console.log(\\"Hello from index.js!\\");

exports[`command: build lint (and fix) should lint and fix Rollup entries only: button/index.js before lint 1`] = `
"import Vue from 'vue';
import Button from './Button.vue';
import Button from './Button';
Vue.component('y-button', Button);
Expand Down

0 comments on commit 249a4b4

Please sign in to comment.