Skip to content

Commit

Permalink
feat: dedicated entrypoint for the decorator
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `Socket` decorates is no longer exported out of the root entry point of `vue-socket.io-extended`, use the separate entrypoint instead:

```diff
- import { Socket } from 'vue-socket.io-extended'
+ import Socket from 'vue-socket.io-extended/decorator'
```
  • Loading branch information
probil committed Jan 18, 2021
1 parent d978515 commit df83685
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 56 deletions.
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
"description": "Socket.io bindings for Vue.js and Vuex (inspired by Vue-Socket.io)",
"main": "dist/vue-socket.io-ext.min.js",
"module": "dist/vue-socket.io-ext.esm.js",
"exports": {
".": {
"import": "./dist/vue-socket.io-ext.esm.js",
"default": "./dist/vue-socket.io-ext.min.js"
},
"./decorator/": "./dist/vue-socket.io-ext.decorator.esm.js"
},
"scripts": {
"test": "jest",
"lint": "eslint scripts src",
Expand All @@ -17,8 +24,7 @@
},
"files": [
"dist/",
"types/index.d.ts",
"types/vue.d.ts"
"types/"
],
"typings": "types/index.d.ts",
"keywords": [
Expand Down
44 changes: 29 additions & 15 deletions scripts/rollup-build.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/* eslint-disable import/no-extraneous-dependencies */
import nodeResolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';
import { terser } from 'rollup-plugin-terser'; // uglifyjs alternative
import commonjs from 'rollup-plugin-commonjs';
import filesize from 'rollup-plugin-filesize';

export default [
{
input: 'src/index.esm.js',
external: ['vue', 'vue-class-component'],
input: 'src/index.js',
external: ['vue'],
plugins: [
nodeResolve(),
commonjs(),
babel(),
terser(), // uglifyjs alternative
terser(),
filesize(),
],
output: {
Expand All @@ -22,22 +22,36 @@ export default [
},
},
{
input: 'src/index.umd.js',
external: ['vue', 'vue-class-component'],
input: 'src/index.js',
external: ['vue'],
plugins: [
nodeResolve(),
commonjs(),
babel(),
terser(), // uglifyjs alternative
terser(),
filesize(),
],
output:
{
format: 'umd',
name: 'VueSocketIOExt',
exports: 'named',
globals: { vue: 'Vue' },
file: 'dist/vue-socket.io-ext.min.js',
},
output: {
format: 'umd',
name: 'VueSocketIOExt',
exports: 'named',
globals: { vue: 'Vue' },
file: 'dist/vue-socket.io-ext.min.js',
},
},
{
input: 'src/decorator.js',
external: ['vue-class-component'],
plugins: [
nodeResolve(),
commonjs(),
babel(),
terser(),
filesize(),
],
output: {
format: 'esm',
file: 'dist/vue-socket.io-ext.decorator.esm.js',
},
},
];
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import VueSocketIoExt, { Socket } from '../index.esm';
import VueSocketIoExt from '../index';

it('default export should be a vue plugin', () => {
expect(VueSocketIoExt).toMatchObject({
Expand All @@ -11,7 +11,3 @@ it('default export should have `defaults` options exported', () => {
defaults: expect.any(Object),
});
});

it('named export `Socket` exists', () => {
expect(Socket).toEqual(expect.any(Function));
});
19 changes: 0 additions & 19 deletions src/__tests__/index.umd.spec.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/index.esm.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as plugin from './plugin';

export default plugin;
8 changes: 0 additions & 8 deletions src/index.umd.js

This file was deleted.

0 comments on commit df83685

Please sign in to comment.