Yuki Takei 3 лет назад
Родитель
Сommit
df9301c944

+ 1 - 0
package.json

@@ -55,6 +55,7 @@
   "devDependencies": {
   "devDependencies": {
     "@swc/core": "^1.3.35",
     "@swc/core": "^1.3.35",
     "@swc/helpers": "^0.4.14",
     "@swc/helpers": "^0.4.14",
+    "@swc/jest": "^0.2.24",
     "@testing-library/cypress": "^8.0.2",
     "@testing-library/cypress": "^8.0.2",
     "@types/css-modules": "^1.0.2",
     "@types/css-modules": "^1.0.2",
     "@types/jest": "^26.0.22",
     "@types/jest": "^26.0.22",

+ 5 - 5
packages/core/package.json

@@ -6,16 +6,16 @@
   "keywords": [
   "keywords": [
     "growi"
     "growi"
   ],
   ],
-  "main": "dist/cjs/index.js",
-  "module": "dist/esm/index.js",
+  "main": "dist/core.umd.js",
+  "module": "dist/core.mjs",
   "files": [
   "files": [
     "dist"
     "dist"
   ],
   ],
   "scripts": {
   "scripts": {
-    "build": "run-p build:*",
-    "build:cjs": "tsc -p tsconfig.build.cjs.json && tsc-alias -p tsconfig.build.cjs.json",
-    "build:esm": "tsc -p tsconfig.build.esm.json && tsc-alias -p tsconfig.build.esm.json",
+    "build": "tsc && vite build",
     "clean": "npx -y shx rm -rf dist",
     "clean": "npx -y shx rm -rf dist",
+    "dev": "vite build --mode dev -w",
+    "dev:nowatch": "vite build --mode dev",
     "lint:js": "eslint **/*.{js,ts}",
     "lint:js": "eslint **/*.{js,ts}",
     "lint": "npm-run-all -p lint:*",
     "lint": "npm-run-all -p lint:*",
     "test": "jest --verbose"
     "test": "jest --verbose"

+ 0 - 11
packages/core/tsconfig.base.json

@@ -1,11 +0,0 @@
-{
-  "extends": "../../tsconfig.base.json",
-  "compilerOptions": {
-  },
-  "include": [
-    "src"
-  ],
-  "exclude": [
-    "src/test"
-  ]
-}

+ 0 - 18
packages/core/tsconfig.build.esm.json

@@ -1,18 +0,0 @@
-{
-  "extends": "./tsconfig.base.json",
-  "compilerOptions": {
-    "module": "esnext",
-
-    "rootDir": "./src",
-    "outDir": "dist/esm",
-    "declaration": true,
-    "noResolve": false,
-    "preserveConstEnums": true,
-    "sourceMap": false,
-    "noEmit": false,
-
-    "baseUrl": ".",
-    "paths": {
-    }
-  }
-}

+ 2 - 2
packages/core/tsconfig.build.cjs.json → packages/core/tsconfig.build.json

@@ -1,8 +1,8 @@
 {
 {
-  "extends": "./tsconfig.base.json",
+  "extends": "./tsconfig.json",
   "compilerOptions": {
   "compilerOptions": {
     "rootDir": "./src",
     "rootDir": "./src",
-    "outDir": "dist/cjs",
+    "outDir": "dist",
     "declaration": true,
     "declaration": true,
     "noResolve": false,
     "noResolve": false,
     "preserveConstEnums": true,
     "preserveConstEnums": true,

+ 5 - 2
packages/core/tsconfig.json

@@ -1,9 +1,12 @@
 {
 {
-  "extends": "./tsconfig.base.json",
+  "extends": "../../tsconfig.base.json",
   "compilerOptions": {
   "compilerOptions": {
     "baseUrl": ".",
     "baseUrl": ".",
     "paths": {
     "paths": {
       "~/*": ["./src/*"]
       "~/*": ["./src/*"]
     }
     }
-  }
+  },
+  "include": [
+    "src"
+  ]
 }
 }

+ 13 - 0
packages/core/vite.config.ts

@@ -0,0 +1,13 @@
+import { defineConfig } from 'vite';
+
+// https://vitejs.dev/config/
+export default defineConfig({
+  build: {
+    outDir: 'dist',
+    lib: {
+      entry: 'src/index.ts',
+      name: 'core-libs',
+      formats: ['umd'],
+    },
+  },
+});

+ 1 - 1
tsconfig.base.json

@@ -1,7 +1,7 @@
 {
 {
   "compilerOptions": {
   "compilerOptions": {
     "target": "es2019",
     "target": "es2019",
-    "module": "commonjs",
+    "module": "esnext",
     "allowJs": true,
     "allowJs": true,
     "skipLibCheck": true,
     "skipLibCheck": true,
     "importHelpers": true,
     "importHelpers": true,

+ 31 - 0
yarn.lock

@@ -2029,6 +2029,13 @@
     slash "^3.0.0"
     slash "^3.0.0"
     strip-ansi "^6.0.0"
     strip-ansi "^6.0.0"
 
 
+"@jest/create-cache-key-function@^27.4.2":
+  version "27.5.1"
+  resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-27.5.1.tgz#7448fae15602ea95c828f5eceed35c202a820b31"
+  integrity sha512-dmH1yW+makpTSURTy8VzdUwFnfQh1G8R+DxO2Ho2FFmBbKFEVm+3jWdvFhE2VqB/LATCTokkP0dotjyQyw5/AQ==
+  dependencies:
+    "@jest/types" "^27.5.1"
+
 "@jest/environment@^28.1.3":
 "@jest/environment@^28.1.3":
   version "28.1.3"
   version "28.1.3"
   resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-28.1.3.tgz#abed43a6b040a4c24fdcb69eab1f97589b2d663e"
   resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-28.1.3.tgz#abed43a6b040a4c24fdcb69eab1f97589b2d663e"
@@ -2185,6 +2192,17 @@
     "@types/yargs" "^16.0.0"
     "@types/yargs" "^16.0.0"
     chalk "^4.0.0"
     chalk "^4.0.0"
 
 
+"@jest/types@^27.5.1":
+  version "27.5.1"
+  resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.5.1.tgz#3c79ec4a8ba61c170bf937bcf9e98a9df175ec80"
+  integrity sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==
+  dependencies:
+    "@types/istanbul-lib-coverage" "^2.0.0"
+    "@types/istanbul-reports" "^3.0.0"
+    "@types/node" "*"
+    "@types/yargs" "^16.0.0"
+    chalk "^4.0.0"
+
 "@jest/types@^28.1.3":
 "@jest/types@^28.1.3":
   version "28.1.3"
   version "28.1.3"
   resolved "https://registry.yarnpkg.com/@jest/types/-/types-28.1.3.tgz#b05de80996ff12512bc5ceb1d208285a7d11748b"
   resolved "https://registry.yarnpkg.com/@jest/types/-/types-28.1.3.tgz#b05de80996ff12512bc5ceb1d208285a7d11748b"
@@ -2901,6 +2919,14 @@
   dependencies:
   dependencies:
     tslib "^2.4.0"
     tslib "^2.4.0"
 
 
+"@swc/jest@^0.2.24":
+  version "0.2.24"
+  resolved "https://registry.yarnpkg.com/@swc/jest/-/jest-0.2.24.tgz#35d9377ede049613cd5fdd6c24af2b8dcf622875"
+  integrity sha512-fwgxQbM1wXzyKzl1+IW0aGrRvAA8k0Y3NxFhKigbPjOJ4mCKnWEcNX9HQS3gshflcxq8YKhadabGUVfdwjCr6Q==
+  dependencies:
+    "@jest/create-cache-key-function" "^27.4.2"
+    jsonc-parser "^3.2.0"
+
 "@testing-library/cypress@^8.0.2":
 "@testing-library/cypress@^8.0.2":
   version "8.0.2"
   version "8.0.2"
   resolved "https://registry.yarnpkg.com/@testing-library/cypress/-/cypress-8.0.2.tgz#b13f0ff2424dec4368b6670dfbfb7e43af8eefc9"
   resolved "https://registry.yarnpkg.com/@testing-library/cypress/-/cypress-8.0.2.tgz#b13f0ff2424dec4368b6670dfbfb7e43af8eefc9"
@@ -12125,6 +12151,11 @@ json5@^2.0.0, json5@^2.1.1, json5@^2.1.2, json5@^2.2.0, json5@^2.2.1:
   resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
   resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
   integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
   integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
 
 
+jsonc-parser@^3.2.0:
+  version "3.2.0"
+  resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76"
+  integrity sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==
+
 jsonfile@^4.0.0:
 jsonfile@^4.0.0:
   version "4.0.0"
   version "4.0.0"
   resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
   resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"