Skip to content

Commit

Permalink
chore: move next admin packages to core repo (#5983)
Browse files Browse the repository at this point in the history
**What**
- Move packages for `next` version of admin to core repo

**Other**
- Since this PR introduces packages that depend on Vite 5, it also introduces @types/node@^20. We have never had a direct dependency on the types package for Node, and as far as I can see that has resulted in us using the types from Node.js@8, as those are a dependency of one of our dependencies. With the introduction of @types/node@^20, two of our packages had TS errors because they were using the NodeJS.Timer type, which was deprecated in Node.js@14. We should add specific @types/node packages to all our packages, but I haven't done so in this PR to keep it as clean as possible.
- Q: @olivermrbl I've added the new packages to the ignore list for changeset, is this enough to prevent them from being published?
  • Loading branch information
kasperkristensen authored Jan 8, 2024
1 parent 479a8b8 commit f868775
Show file tree
Hide file tree
Showing 491 changed files with 11,332 additions and 428 deletions.
11 changes: 9 additions & 2 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
"access": "public",
"baseBranch": "develop",
"updateInternalDependencies": "patch",
"ignore": ["integration-tests-api", "integration-tests-plugins", "integration-tests-repositories"],
"ignore": [
"integration-tests-api",
"integration-tests-plugins",
"integration-tests-repositories",
"@medusajs/dashboard",
"@medusajs/admin-shared",
"@medusajs/admin-bundler",
"@medusajs/vite-plugin-extension"
],
"snapshot": {
"useCalculatedVersion": true
},
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
}

}
7 changes: 7 additions & 0 deletions .changeset/hip-squids-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"create-medusa-app": patch
"medusa-core-utils": patch
---

fix(create-medusa-app,medusa-core-utils): Use NodeJS.Timeout instead of NodeJS.Timer as the latter was deprecated in v14.
chore(icons): Update icons to latest version.
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,27 @@ module.exports = {
],
},
},
{
files: ["packages/admin-next/dashboard/**/*"],
env: { browser: true, es2020: true, node: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./packages/admin-next/dashboard/tsconfig.json",
},
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
{
files: ["packages/admin-ui/lib/**/*.ts"],
parser: "@typescript-eslint/parser",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"packages/medusa-js",
"packages/medusa-react",
"packages/*",
"packages/admin-next/*",
"packages/design-system/*",
"packages/generated/*",
"packages/oas/*",
Expand Down Expand Up @@ -38,6 +39,7 @@
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"eslint-plugin-storybook": "^0.6.12",
"eslint-plugin-unused-imports": "^2.0.0",
"express": "^4.17.1",
Expand Down
1 change: 1 addition & 0 deletions packages/admin-next/admin-bundler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# cli
6 changes: 6 additions & 0 deletions packages/admin-next/admin-bundler/bin/medusa-admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node
function start() {
return import("../dist/cli/index.mjs");
}

start();
34 changes: 34 additions & 0 deletions packages/admin-next/admin-bundler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@medusajs/admin-bundler",
"version": "0.0.0",
"scripts": {
"build": "rimraf dist && tsup"
},
"bin": {
"medusa-admin": "./bin/medusa-admin.js"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.mjs",
"files": [
"dist"
],
"devDependencies": {
"rimraf": "5.0.1",
"tsup": "^8.0.1",
"typescript": "^5.3.3"
},
"dependencies": {
"@medusajs/ui-preset": "^1.0.2",
"@medusajs/vite-plugin-extension": "*",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.16",
"commander": "^11.1.0",
"deepmerge": "^4.3.1",
"glob": "^7.1.6",
"postcss": "^8.4.32",
"tailwindcss": "^3.3.6",
"vite": "5.0.10"
},
"packageManager": "yarn@3.2.1"
}
22 changes: 22 additions & 0 deletions packages/admin-next/admin-bundler/src/api/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { resolve } from "path"
import { build as command } from "vite"

import { createViteConfig } from "./create-vite-config"

type BuildArgs = {
root?: string
}

export async function build({ root }: BuildArgs) {
const config = await createViteConfig({
build: {
outDir: resolve(process.cwd(), "build"),
},
})

if (!config) {
return
}

await command(config)
}
46 changes: 46 additions & 0 deletions packages/admin-next/admin-bundler/src/api/bundle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { readFileSync } from "fs"
import glob from "glob"
import { relative, resolve } from "path"
import { build as command } from "vite"

type BundleArgs = {
root?: string | undefined
watch?: boolean | undefined
}

export async function bundle({ watch, root }: BundleArgs) {
const resolvedRoot = root
? resolve(process.cwd(), root)
: resolve(process.cwd(), "src", "admin")

const files = glob.sync(`${resolvedRoot}/**/*.{ts,tsx,js,jsx}`)

const input: Record<string, string> = {}
for (const file of files) {
const relativePath = relative(resolvedRoot, file)
input[relativePath] = file
}

const packageJson = JSON.parse(
readFileSync(resolve(process.cwd(), "package.json"), "utf-8")
)
const external = [
...Object.keys(packageJson.dependencies),
"@medusajs/ui",
"@medusajs/ui-preset",
"react",
"react-dom",
"react-router-dom",
"react-hook-form",
]

await command({
build: {
watch: watch ? {} : undefined,
rollupOptions: {
input: input,
external: external,
},
},
})
}
Loading

0 comments on commit f868775

Please sign in to comment.