Skip to content

Commit 79d0ff3

Browse files
authoredJun 1, 2020
chore: update repo (#34)
1 parent 0b76ddd commit 79d0ff3

18 files changed

+2982
-2387
lines changed
 

‎.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
["@babel/env", { "targets": { "node": 10 }}]
4+
]
5+
}

‎.commitlintrc.js

-5
This file was deleted.

‎.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dist
33
.nuxt
44
coverage
55
templates
6-
src/installComponents.js
6+
lib/installComponents.js

‎.huskyrc.js

-6
This file was deleted.

‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) [Nuxt.js Team](https://github.com/orgs/nuxt/people)
3+
Copyright (c) Nuxt.js Team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,7 @@ Next: publish your `awesome-ui` module to [npm](https://www.npmjs.com) and share
317317
318318
## License
319319
320-
[MIT License](./LICENSE)
321-
322-
Copyright (c) Nuxt.js Team
320+
[MIT](./LICENSE)
323321
324322
<!-- Badges -->
325323

‎babel.config.js

-18
This file was deleted.

‎jest.config.js

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
module.exports = {
22
testEnvironment: 'node',
3-
transform: {
4-
'^.+\\.ts$': 'ts-jest',
5-
'^.+\\.js$': 'babel-jest'
6-
},
3+
preset: 'ts-jest',
4+
collectCoverage: true,
75
globals: {
86
'ts-jest': {
97
tsConfig: 'tsconfig.test.json',
108
diagnostics: {
119
ignoreCodes: [2345]
1210
}
1311
}
14-
},
15-
collectCoverage: true,
16-
collectCoverageFrom: [
17-
'src/**/*.ts'
18-
]
19-
// coverageThreshold: {
20-
// global: {
21-
// branches: 100,
22-
// functions: 100,
23-
// lines: 100,
24-
// statements: 100
25-
// }
26-
// }
12+
}
2713
}
File renamed without changes.

‎package.json

+21-24
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,52 @@
44
"description": "Auto Import Components for Nuxt.js",
55
"repository": "nuxt/components",
66
"license": "MIT",
7-
"contributors": [
8-
{
9-
"name": "Kevin Marrec (@kevinmarrec)"
10-
},
11-
{
12-
"name": "Ricardo Gobbo de Souza",
13-
"email": "ricardogobbosouza@yahoo.com.br"
14-
},
15-
{
16-
"name": "Pooya Parsa",
17-
"email": "pooya@nuxtjs.com"
18-
}
19-
],
207
"main": "dist/index.js",
21-
"typings": "dist/index.d.ts",
8+
"types": "dist/index.d.ts",
229
"files": [
2310
"dist",
11+
"lib",
2412
"templates"
2513
],
2614
"scripts": {
27-
"build": "yarn clean && tsc",
15+
"build": "yarn clean && bili src/index.ts",
2816
"clean": "rimraf dist",
29-
"dev": "tsc && nuxt-ts test/fixture",
17+
"dev": "nuxt-ts test/fixture",
3018
"lint": "eslint --ext .ts,.js,.vue .",
3119
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
3220
"test": "yarn lint && jest --verbose"
3321
},
22+
"dependencies": {
23+
"chalk": "^4.0.0",
24+
"chokidar": "^3.4.0",
25+
"glob": "^7.1.6",
26+
"lodash": "^4.17.15",
27+
"semver": "^7.3.2"
28+
},
3429
"devDependencies": {
35-
"@commitlint/cli": "latest",
36-
"@commitlint/config-conventional": "latest",
30+
"@babel/preset-env": "^7.10.2",
3731
"@nuxt/typescript-build": "latest",
3832
"@nuxt/typescript-runtime": "latest",
3933
"@nuxtjs/eslint-config-typescript": "latest",
40-
"@types/glob": "latest",
34+
"@types/glob": "^7.1.1",
4135
"@types/jest": "latest",
4236
"@types/loader-utils": "latest",
4337
"@types/lodash": "latest",
4438
"@types/semver": "latest",
45-
"codecov": "latest",
39+
"bili": "latest",
4640
"eslint": "latest",
47-
"husky": "latest",
4841
"jest": "latest",
4942
"nuxt-edge": "latest",
50-
"pug": "^3.0.0",
51-
"pug-plain-loader": "^1.0.0",
43+
"pug": "latest",
44+
"pug-plain-loader": "latest",
5245
"rimraf": "latest",
46+
"rollup-plugin-typescript2": "latest",
5347
"standard-version": "latest",
5448
"ts-jest": "latest",
55-
"typescript": "~3.8"
49+
"typescript": "latest"
50+
},
51+
"peerDependencies": {
52+
"webpack": "*"
5653
},
5754
"publishConfig": {
5855
"access": "public"

‎renovate.json

-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
},
88
"labels": [
99
"dependencies"
10-
],
11-
"ignoreDeps": [
12-
"typescript"
1310
]
1411
}

‎src/index.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface Options {
3636
const isPureObjectOrString = (val: any) => (!Array.isArray(val) && typeof val === 'object') || typeof val === 'string'
3737
const getDir = (p: string) => fs.statSync(p).isDirectory() ? p : path.dirname(p)
3838

39-
export default <Module> function () {
39+
const componentsModule = <Module> function () {
4040
requireNuxtVersion.call(this, '2.10')
4141

4242
const { components } = this.options
@@ -137,7 +137,12 @@ export default <Module> function () {
137137
// Add Webpack entry for runtime installComponents function
138138
this.nuxt.hook('webpack:config', (configs: WebpackConfig[]) => {
139139
for (const config of configs.filter(c => ['client', 'modern', 'server'].includes(c.name!))) {
140-
((config.entry as WebpackEntry).app as string[]).unshift(path.resolve(__dirname, 'installComponents.js'))
140+
((config.entry as WebpackEntry).app as string[]).unshift(path.resolve(__dirname, '../lib/installComponents.js'))
141141
}
142142
})
143143
}
144+
145+
// @ts-ignore
146+
componentsModule.meta = { name: '@nuxt/components' }
147+
148+
export default componentsModule

‎src/loader.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import loaderUtils from 'loader-utils'
33
import { extractTags } from './tagExtractor'
44
import { Component, matcher } from './scan'
55

6-
interface LoaderOptions {
7-
dependencies: string[]
8-
getComponents(): Component[]
9-
}
10-
116
function install (this: WebpackLoader.LoaderContext, content: string, components: Component[]) {
127
const imports = '{' + components.map(c => `${c.pascalName}: ${c.import}`).join(',') + '}'
138

@@ -32,7 +27,11 @@ export default async function loader (this: WebpackLoader.LoaderContext, content
3227
if (!this.resourceQuery) {
3328
this.addDependency(this.resourcePath)
3429

35-
const { dependencies, getComponents } = loaderUtils.getOptions(this) as LoaderOptions
30+
const { dependencies, getComponents } = {
31+
dependencies: [],
32+
getComponents: () => [],
33+
...loaderUtils.getOptions(this)
34+
}
3635

3736
for (const dependency of dependencies) {
3837
this.addDependency(dependency)

‎test/fixture/nuxt.config.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import path from 'path'
22
import { Configuration } from '@nuxt/types'
3-
import componentsModule from '../../src'
3+
import nuxtComponents from '../../src'
44

55
const config: Configuration = {
6-
rootDir: path.resolve(__dirname, '../..'),
7-
buildDIr: path.resolve(__dirname, '.nuxt'),
8-
srcDir: __dirname,
9-
10-
buildModules: ['@nuxt/typescript-build', componentsModule],
6+
buildModules: [
7+
'@nuxt/typescript-build',
8+
nuxtComponents
9+
],
1110

1211
components: {
1312
dirs: [

‎test/module.test.ts ‎test/module.ts

File renamed without changes.

‎tsconfig.json

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
{
22
"compilerOptions": {
3-
"target": "esnext",
4-
"lib": ["dom", "esnext"],
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "Node",
56
"outDir": "dist",
67
"declaration": true,
7-
"sourceMap": true,
8-
"module": "CommonJS",
9-
"moduleResolution": "node",
10-
"allowJs": true,
11-
"skipLibCheck": true,
128
"esModuleInterop": true,
139
"strict": true,
1410
"noFallthroughCasesInSwitch": true,
1511
"noImplicitReturns": true,
1612
"stripInternal": true,
1713
"noUnusedLocals": true
1814
},
19-
"include": ["src"]
15+
"include": [
16+
"src"
17+
]
2018
}

‎tsconfig.test.json

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
{
2+
"extends": "./tsconfig.json",
23
"compilerOptions": {
3-
"target": "esnext",
4-
"lib": ["dom", "esnext"],
5-
"module": "esnext",
6-
"moduleResolution": "node",
7-
"skipLibCheck": true,
8-
"esModuleInterop": true,
9-
"strict": true,
10-
"noImplicitAny": false,
11-
"noFallthroughCasesInSwitch": true,
12-
"noImplicitReturns": true,
13-
"stripInternal": true,
14-
"noUnusedLocals": true
4+
"strict": false,
5+
"target": "ES2019",
6+
"module": "CommonJS"
157
},
16-
"include": ["test"]
8+
"include": [
9+
"test"
10+
]
1711
}

‎yarn.lock

+2,920-2,274
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.