Skip to content

Commit

Permalink
Update readme and changelog, remove autoinstall (anti-pattern)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dodge committed Sep 4, 2020
1 parent 754152c commit 15fe1b7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 64 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.0.0-beta.0] - 2020-09-04
- **NEW**: Vue 3 support! Select target version of Vue - components compiled for Vue 3 are not compatible with Vue 2
- Update cli dependencies
- chalk 4.1.0
- ejs 3.1.5
- eslint 7.7.0
- eslint-config-airbnb-base 14.2.0
- eslint-plugin-import 2.22.0
- Update templates depending on Vue version selected
- **BREAKING CHANGE**: Remove auto-install logic/output entirely
- Auto-install has become an anti-pattern, since Vue 3 will not allow registering components/libraries globally
- **BREAKING CHANGE**: Non-esm builds now attach named exports as properties of the default export
- Nodejs/browser usage is now registered via `Vue.use(globalVar)` instead of `Vue.use(globalVar.default)`, with named exports still accessed as `globalVar.named1`, `globalVar.named2` etc.
- Update template dependencies
- @babel/core 7.11.0
- @babel/preset-env 7.11.0
- @babel/preset-typescript 7.10.4
- @rollup/plugin-alias 3.1.1
- @rollup/plugin-babel 5.2.0
- @rollup/plugin-commonjs 14.0.0
- **NEW** @rollup/node-resolve 9.0.0
- @rollup/plugin-replace 2.3.3
- @vue/cli-plugin-babel 4.5.4
- @vue/cli-plugin-typescript 4.5.4
- @vue/cli-service 4.5.4
- @vue/compiler-sfc 3.0.0-rc.9 (Vue 3 only)
- rollup 2.26.5
- **NEW** rollup-plugin-postcss 3.1.6 (Vue 3 only)
- rollup-plugin-terser 7.0.0
- rollup-plugin-vue 5.1.9 (Vue 2) / 6.0.0-beta.10 (Vue 3)
- vue 2.6.12 (Vue 2) / 3.0.0-rc.9 (Vue 3)
- vue-template-compiler 2.6.12 (Vue 2 only)

## [3.0.1] - 2020-06-05

### Fixed
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ npm run build

## Details

The vue-sfc-rollup utility scaffolds 8-13 files (depending on whether you choose library mode and/or typescript support) for you to kick of your SFC development. These files include:
The vue-sfc-rollup utility scaffolds the essential files you need to kick of your SFC development. These files include:
- a minimal [rollup](https://rollupjs.org) config
- a corresponding package.json file with build/dev scripts and dependencies
- a minimal babel.config.js and .browserslistrc file for transpiling
- a wrapper used by rollup when packaging your SFC
- two wrappers used by rollup when packaging your SFC
- a sample SFC to kick-start development
- a sample usage file which can be used to load/test your component/library during development

In library mode, there is also an 'index' which declares the components exposed as part of your library.

When developing typescript-based components/libraries, the following supporting files will also be created:
- A basic typescript declaration file for your component/library
- Two basic typescript shim declaration files common to vue-typescript development
- The basic typescript shim declaration file(s) common to vue-typescript development
- A basic tsconfig.json file

If you wish to integrate this into an existing SFC, please check out [the vue-sfc-rollup source](https://github.com/team-innovation/vue-sfc-rollup). The files generated by this utility are located inside the `templates` directory of the repository. Merge the important bits of those file with your existing code, and you'll be good to go.
Expand All @@ -72,6 +72,7 @@ sfc-init
```
The wizard will then prompt you for the following:

- *select vue version*: Declare whether you are writing a component for Vue 2 or Vue 3
- *select mode*: Declare whether you want to scaffold a single component or a library of components.
- *npm name*: This is how people will find your component/library in npm. Please refer to [the official npm docs](https://docs.npmjs.com/files/package.json#name) for details of what to enter here
- *component name* (Single Component Mode Only): This is the kebab-case version of your SFC component name - what your component's tag would be if you were to use this in an HTML page or another component. Since any kebab-case tag name would also be a safe file name, this will also be the name of the generated files.
Expand All @@ -82,7 +83,7 @@ After prompting you for this information, the wizard then creates copies of the

### Developing your SFC

vue-sfc-rollup is focused on packaging your SFC for distribution via npm. The [Vue CLI](https://cli.vuejs.org/) is excellent for the actual development process of your SFC, and vue-sfc-rollup comes pre-wired to use this process. With v3 of the Vue CLI installed, you can truly develop your SFC with zero configuration just by entering the following commands:
vue-sfc-rollup is focused on packaging your SFC for distribution via npm. The [Vue CLI](https://cli.vuejs.org/) is excellent for the actual development process of your SFC, and vue-sfc-rollup comes pre-wired to use this process. With the Vue CLI installed, you can truly develop your SFC with zero configuration just by entering the following commands:

```bash
# Navigate to library folder
Expand Down Expand Up @@ -110,4 +111,4 @@ npm run build
# Ready to publish!
```

Running the build script results in 3 compiled files in the `dist` directory, one for each of the `main`, `module`, and `unpkg` properties listed in your package.json file. With these files are generated, you're ready to go!
Running the build script results in 3 compiled files in the `dist` directory, one for each of the `main`, `module`, and `unpkg` properties listed in your package.json file. With these files generated, you're ready to go!
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Quickly generate redistributable components with Rollup",
"author": "Michael Dodge",
"license": "ISC",
"version": "3.0.1",
"version": "4.0.0-beta.0",
"bin": {
"sfc-init": "./sfc-init.js"
},
Expand Down
32 changes: 2 additions & 30 deletions templates/library/src/entry.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<% if (ts) {
if (version === 3) { -%>
<% if (ts && version === 3) { -%>
import { defineComponent, Plugin } from 'vue';

<% } else { -%>
import _Vue from 'vue';

<% }
} -%>
<% } -%>
// iife/cjs usage extends esm default export - so import it all
// import * as components from '@/lib-components/index';
import plugin, * as components from '@/entry.esm';
Expand All @@ -26,26 +21,3 @@ Object.entries(components).forEach(([componentName, component]) => {
});

export default plugin;
<% if (version === 2) { -%>
// To auto-install on non-es builds, when vue is found
// eslint-disable-next-line no-redeclare
/* global window, global */
let GlobalVue = null;
if (typeof window !== 'undefined') {
GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
<% if (ts) { -%>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
GlobalVue = (global as any).Vue;
<% } else { -%>
GlobalVue = global.Vue;
<% } -%>
}
if (GlobalVue) {
<% if (ts) { -%>
(GlobalVue as typeof _Vue).use(plugin);
<% } else { -%>
GlobalVue.use(plugin);
<% } -%>
}
<% } -%>
27 changes: 0 additions & 27 deletions templates/single/src/entry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<% if (ts && version === 2) { -%>
import _Vue from 'vue';

<% } -%>
// iife/cjs usage extends esm default export - so import it all
import component /* , { RollupDemoDirective } */ from '@/entry.esm';

Expand All @@ -11,26 +7,3 @@ import component /* , { RollupDemoDirective } */ from '@/entry.esm';
// component.RollupDemoDirective = RollupDemoDirective;

export default component;
<% if (version === 2) { -%>
// To auto-install on non-es builds, when vue is found
// eslint-disable-next-line no-redeclare
/* global window, global */
let GlobalVue = null;
if (typeof window !== 'undefined') {
GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
<% if (ts) { -%>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
GlobalVue = (global as any).Vue;
<% } else { -%>
GlobalVue = global.Vue;
<% } -%>
}
if (GlobalVue) {
<% if (ts) { -%>
(GlobalVue as typeof _Vue).use(component);
<% } else { -%>
GlobalVue.use(component);
<% } -%>
}
<% } -%>

0 comments on commit 15fe1b7

Please sign in to comment.