Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 3917bd6

Browse files
Merge pull request #17 from chakra-ui/refactor/dev-environment
Refactor/dev environment
2 parents ce8db6e + c6e3c90 commit 3917bd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+703
-778
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
node-version: [12.x]
20+
node-version: [12.19]
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v2

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Use Node.js 12.x
2626
uses: actions/setup-node@master
2727
with:
28-
node-version: 12.x
28+
node-version: 12.19
2929

3030
- name: Install dependencies
3131
run: yarn install --frozen-lockfile && yarn bootstrap

_templates/generator/component/package.json.ejs.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ to: packages/<%=h.changeCase.paramCase(name)%>/package.json
3030
"sideEffects": false,
3131
"scripts": {
3232
"build": "concurrently yarn:build:*",
33-
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps",
34-
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps",
35-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
33+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx -d dist/esm --source-maps",
34+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts,.tsx -d dist/cjs --source-maps",
35+
"build:types": "cross-env tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
3636
"watch": "concurrently yarn:watch:*",
37-
"watch:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps --watch",
38-
"watch:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps --watch",
39-
"watch:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types --watch"
37+
"watch:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx -d dist/esm --source-maps --watch",
38+
"watch:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts,.tsx -d dist/cjs --source-maps --watch",
39+
"watch:types": "cross-env tsc --emitDeclarationOnly --declaration --declarationDir dist/types --watch"
4040
},
4141
"dependencies": {
4242
"@chakra-ui/styled-system": "^1.4.1",

_templates/generator/module/package.json.ejs.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ to: packages/<%=h.changeCase.paramCase(name)%>/package.json
1818
"license": "MIT",
1919
"scripts": {
2020
"build": "concurrently yarn:build:*",
21-
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps",
22-
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps",
21+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx -d dist/esm --source-maps",
22+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts,.tsx -d dist/cjs --source-maps",
2323
"watch": "concurrently yarn:watch:*",
24-
"watch:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps --watch",
25-
"watch:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps --watch",
26-
"watch:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types --watch"
24+
"watch:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx -d dist/esm --source-maps --watch",
25+
"watch:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts,.tsx -d dist/cjs --source-maps --watch",
26+
"watch:types": "cross-env tsc --emitDeclarationOnly --declaration --declarationDir dist/types --watch"
2727
}
2828
}

babel.config.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ const BABEL_ENV = process.env.BABEL_ENV
22
const isCommonJS = BABEL_ENV !== undefined && BABEL_ENV === 'cjs'
33
const isESM = BABEL_ENV !== undefined && BABEL_ENV === 'esm'
44

5-
module.exports = function (api) {
5+
const __TEST__ = process.env.NODE_ENV === 'test'
6+
7+
const baseConfig = function (api) {
68
api.cache(true)
79

810
const presets = [
@@ -18,8 +20,28 @@ module.exports = function (api) {
1820
],
1921
'@babel/preset-typescript',
2022
]
23+
const plugins = ['@vue/babel-plugin-jsx']
2124

2225
return {
2326
presets,
27+
plugins,
2428
}
2529
}
30+
31+
const testConfig = {
32+
env: {
33+
test: {
34+
presets: [
35+
[
36+
'@babel/preset-env',
37+
{
38+
targets: { node: true },
39+
},
40+
],
41+
],
42+
plugins: ['@vue/babel-plugin-jsx'],
43+
},
44+
},
45+
}
46+
47+
module.exports = __TEST__ ? testConfig : baseConfig

global.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export {}
2+
declare global {
3+
namespace JSX {
4+
export interface IntrinsicAttributes {
5+
as?: string
6+
label?: string
7+
poop?: 'name' | 'hard' | 'soft'
8+
}
9+
}
10+
}

jest.config.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
module.exports = {
2-
preset: 'ts-jest',
3-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'vue'],
42
transform: {
5-
'^.+\\.vue$': 'vue-jest',
6-
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
7-
'jest-transform-stub',
8-
'^.+\\.(ts|jsx)?$': 'ts-jest',
3+
'^.+\\.(ts|tsx)$': 'ts-jest',
94
},
105
transformIgnorePatterns: ['/node_modules/(?!lodash.)'],
116
moduleNameMapper: {
@@ -16,13 +11,10 @@ module.exports = {
1611
'@chakra-ui/vue-test-utils/dist/cjs/snapshot-serializer.js',
1712
],
1813
testMatch: ['**/**/*.test.(js|jsx|ts|tsx)'],
19-
testURL: 'http://localhost/',
2014
testEnvironmentOptions: { resources: 'usable' },
2115
globals: {
2216
'ts-jest': {
23-
tsconfig: {
24-
target: 'ES2019',
25-
},
17+
babelConfig: 'babel.config.js',
2618
},
2719
},
2820
}

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
"bootstrap": "yarn run lerna bootstrap",
1414
"scaffold": "hygen",
1515
"build": "lerna run build --no-private --stream",
16-
"dev": "concurrently 'ts-node ./scripts/watch-files.ts' 'NODE_ENV=development vite serve playground --config ./vite.config.ts'",
17-
"playground:routes": "ts-node ./scripts/parse-routes.ts",
18-
"playground:build": "yarn install && yarn build && yarn playground:routes && NODE_ENV=production vite build playground --config ./vite.config.ts",
19-
"test": "jest",
16+
"dev": "NODE_ENV=development vite serve playground --config ./vite.config.ts",
17+
"playground:build": "yarn install && yarn build && yarn bootstrap && NODE_ENV=production vite build playground --config ./vite.config.ts",
18+
"test": "cross-env NODE_ENV=test jest --config jest.config.js",
2019
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
2120
"core": "yarn workspace @chakra-ui/vue-next",
2221
"c-alert": "yarn workspace @chakra-ui/c-alert",
@@ -49,6 +48,7 @@
4948
"@typescript-eslint/eslint-plugin": "^2.34.0",
5049
"@typescript-eslint/parser": "4.0.1",
5150
"@vitejs/plugin-vue": "^1.0.6",
51+
"@vue/babel-plugin-jsx": "^1.0.3",
5252
"@vue/compiler-sfc": "^3.0.5",
5353
"@vue/eslint-config-typescript": "^5.1.0",
5454
"@vuedx/typecheck": "^0.4.1",
@@ -58,6 +58,7 @@
5858
"concurrently": "^5.3.0",
5959
"consola": "^2.15.0",
6060
"cross-env": "^7.0.2",
61+
"esbuild-jest": "^0.4.0",
6162
"eslint": "^7.0.0",
6263
"eslint-config-prettier": "^6.12.0",
6364
"eslint-config-standard": "^14.1.1",
@@ -82,6 +83,8 @@
8283
"ts-node": "^9.0.0",
8384
"typescript": "^4.1.2",
8485
"vite": "^2.0.0-beta.44",
86+
"vite-plugin-components": "^0.6.6",
87+
"vite-plugin-pages": "^0.3.0",
8588
"vue": "^3.0.5",
8689
"vue-jest": "^5.0.0-alpha.7",
8790
"vue-router": "4.0.0-beta.10"

packages/c-accordion/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"license": "MIT",
1515
"scripts": {
1616
"build": "concurrently yarn:build:*",
17-
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts -d dist/esm --source-maps",
18-
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts -d dist/cjs --source-maps",
19-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types"
17+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx -d dist/esm --source-maps",
18+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts,.tsx -d dist/cjs --source-maps",
19+
"build:types": "cross-env tsc --emitDeclarationOnly --declaration --declarationDir dist/types"
2020
},
2121
"dependencies": {
2222
"@chakra-ui/vue-system": "*"
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
11
<template>
22
<c-alert> HELLO ALERT </c-alert>
33
</template>
4-
5-
<script lang="ts">
6-
import { CAlert } from '@chakra-ui/c-alert/src'
7-
import { defineComponent } from 'vue'
8-
9-
export default defineComponent({
10-
name: 'BaseAlertExample',
11-
components: { CAlert },
12-
})
13-
</script>

0 commit comments

Comments
 (0)