Skip to content

Commit

Permalink
Beaking change: Only build one entrypoint
Browse files Browse the repository at this point in the history
This entry point provides all components, mixins etc as named
exports.
Added vue plugin export `NextcloudVue` so users can register
all components using the vue plugin functionality:
`Vue.use(NextcloudVue)`

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Nov 30, 2022
1 parent ca9acca commit 0cee626
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 55 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"cypress:gui": "cypress open --component",
"cypress:update-snapshots": "cypress run --component --env type=base --config screenshotsFolder=cypress/snapshots/base"
},
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"main": "dist/index.umd.js",
"module": "dist/index.esm.js",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
"import": "./dist/index.esm.js",
"require": "./dist/index.umd.js"
},
"files": [
"CHANGELOG.md",
Expand Down
13 changes: 13 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import * as NcComponents from './components/index.js'

export * from './components/index.js'
export * from './functions/index.js'
export * from './directives/index.js'
export * from './mixins/index.js'
export * from './a11y/index.js'

// Vue plugin to install all components using `Vue.use(NextcloudVue)`
export const NextcloudVue = {
/**
* @param {object} Vue The vue instance
*/
install: Vue => {
Object.values(NcComponents).forEach(component => {
Vue.component(component.name, component)
})
},
}
16 changes: 0 additions & 16 deletions src/install.js

This file was deleted.

38 changes: 3 additions & 35 deletions vite.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import md5 from 'md5'
import glob from 'glob'
import vue from '@vitejs/plugin-vue2'
import { externals } from 'rollup-plugin-node-externals'
import browserslistToEsbuild from 'browserslist-to-esbuild'
import injectProcessEnv from 'rollup-plugin-inject-process-env'
import { loadTranslations } from './resources/translations.mjs'
import { fileURLToPath, URL } from 'url'
import { dirname, join, resolve } from 'path'
import { dirname, resolve } from 'path'
import { defineConfig } from 'vite'
import { readFileSync } from 'fs'

Expand Down Expand Up @@ -83,40 +82,9 @@ export default defineConfig({
},
lib: {
name: 'NextcloudVue',
entry: {
index: resolve(__dirname, 'src/index.js'),
install: join(__dirname, 'src', 'install.js'),
...glob.sync('src/components/*/index.js').reduce((acc, item) => {
const name = item
.replace('/index.js', '')
.replace('src/components/', 'Components/')
acc[name] = join(__dirname, item)
return acc
}, {}),
...glob.sync('src/directives/*/index.js').reduce((acc, item) => {
const name = item
.replace('/index.js', '')
.replace('src/directives/', 'Directives/')
acc[name] = join(__dirname, item)
return acc
}, {}),
...glob.sync('src/functions/*/index.js').reduce((acc, item) => {
const name = item
.replace('/index.js', '')
.replace('src/functions/', 'Functions/')
acc[name] = join(__dirname, item)
return acc
}, {}),
...glob.sync('src/mixins/*/index.js').reduce((acc, item) => {
const name = item
.replace('/index.js', '')
.replace('src/mixins/', 'Mixins/')
acc[name] = join(__dirname, item)
return acc
}, {}),
},
entry: resolve(__dirname, 'src/index.js'),
fileName: (format, entry) => {
return `${entry}.${format.startsWith('es') ? 'mjs' : format}`
return `${entry}.${format === 'es' ? 'esm' : format}.js`
},
},
},
Expand Down

0 comments on commit 0cee626

Please sign in to comment.