From 6139a3467b8ae9ee72f96689f208ec54e9350bb4 Mon Sep 17 00:00:00 2001 From: Christian Llontop Date: Fri, 30 Aug 2024 13:41:06 -0500 Subject: [PATCH] Add parser package in a new monorepo structure --- package.json | 36 +++++-------- packages/core/README.md | 1 + .../core/rspack.config.js | 6 +-- .../core/src}/components/Docutopia.svelte | 0 {src => packages/core/src}/env.d.ts | 0 {src => packages/core/src}/index.ts | 0 tsconfig.json => packages/core/tsconfig.json | 2 +- packages/parser/package.json | 34 +++++++++++++ packages/parser/rspack.config.js | 45 +++++++++++++++++ packages/parser/src/index.ts | 1 + packages/parser/src/parser.ts | 7 +++ packages/parser/tsconfig.json | 24 +++++++++ pnpm-lock.yaml | 50 ++++++++++++++++--- pnpm-workspace.yaml | 9 ++++ 14 files changed, 181 insertions(+), 34 deletions(-) create mode 100644 packages/core/README.md rename rspack.config.js => packages/core/rspack.config.js (86%) rename {src => packages/core/src}/components/Docutopia.svelte (100%) rename {src => packages/core/src}/env.d.ts (100%) rename {src => packages/core/src}/index.ts (100%) rename tsconfig.json => packages/core/tsconfig.json (93%) create mode 100644 packages/parser/package.json create mode 100644 packages/parser/rspack.config.js create mode 100644 packages/parser/src/index.ts create mode 100644 packages/parser/src/parser.ts create mode 100644 packages/parser/tsconfig.json create mode 100644 pnpm-workspace.yaml diff --git a/package.json b/package.json index 93f047f..076dd3f 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,14 @@ { - "name": "docutopia", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "dev": "rspack --watch", - "build": "rspack build", - "svelte-check": "svelte-check --tsconfig ./tsconfig.json", - "lint": "biome format", - "lint:fix": "biome format --write" - }, - "files": ["dist/"], - "devDependencies": { - "@biomejs/biome": "1.8.3", - "@rspack/cli": "^1.0.0", - "@rspack/core": "^1.0.0", - "serve": "^14.2.3", - "svelte": "^4.2.18", - "svelte-check": "^3.8.6", - "svelte-loader": "^3.2.3", - "svelte-preprocess": "^6.0.2", - "ts-loader": "^9.5.1", - "typescript": "^5.5.4" - } + "name": "@docutopia/monorepo", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build": "pnpm recursive run build", + "lint": "pnpm recursive run lint", + "lint:fix": "pnpm recursive run lint:fix" + }, + "keywords": [], + "author": "", + "license": "ISC" } diff --git a/packages/core/README.md b/packages/core/README.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/packages/core/README.md @@ -0,0 +1 @@ + diff --git a/rspack.config.js b/packages/core/rspack.config.js similarity index 86% rename from rspack.config.js rename to packages/core/rspack.config.js index 34169b7..0394c68 100644 --- a/rspack.config.js +++ b/packages/core/rspack.config.js @@ -1,4 +1,4 @@ -import {sveltePreprocess} from "svelte-preprocess"; +import { sveltePreprocess } from "svelte-preprocess"; import { defineConfig } from "@rspack/cli"; export default defineConfig({ @@ -6,7 +6,7 @@ export default defineConfig({ docutopia: "./src/index.ts", }, output: { - path: './dist', + path: "./dist", filename: "[name].js", libraryTarget: "umd", }, @@ -33,7 +33,7 @@ export default defineConfig({ resolve: { extensions: [".ts", ".js", ".svelte"], alias: { - '@': './src', + "@": "./src", }, mainFields: ["svelte", "browser", "module", "main"], }, diff --git a/src/components/Docutopia.svelte b/packages/core/src/components/Docutopia.svelte similarity index 100% rename from src/components/Docutopia.svelte rename to packages/core/src/components/Docutopia.svelte diff --git a/src/env.d.ts b/packages/core/src/env.d.ts similarity index 100% rename from src/env.d.ts rename to packages/core/src/env.d.ts diff --git a/src/index.ts b/packages/core/src/index.ts similarity index 100% rename from src/index.ts rename to packages/core/src/index.ts diff --git a/tsconfig.json b/packages/core/tsconfig.json similarity index 93% rename from tsconfig.json rename to packages/core/tsconfig.json index 30329d5..d220eac 100644 --- a/tsconfig.json +++ b/packages/core/tsconfig.json @@ -20,5 +20,5 @@ } }, "include": ["src/**/*.ts", "src/**/*.svelte"], - "exclude": ["node_modules"] + "exclude": ["node_modules", "dist"] } diff --git a/packages/parser/package.json b/packages/parser/package.json new file mode 100644 index 0000000..5c40868 --- /dev/null +++ b/packages/parser/package.json @@ -0,0 +1,34 @@ +{ + "name": "@docutopia/parser", + "description": "", + "version": "0.1.0", + "author": "Christian Llontop", + "license": "MIT", + "keywords": [], + "type": "module", + "main": "./dist/index.cjs.js", + "module": "./dist/index.esm.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "import": "./dist/index.esm.js", + "require": "./dist/index.cjs.js" + } + }, + "bin": { + "docuparser": "./dist/cli.js" + }, + "scripts": { + "build": "rspack build", + "lint": "biome format", + "lint:fix": "biome format --write" + }, + "files": ["dist/"], + "devDependencies": { + "@biomejs/biome": "catalog:", + "@rspack/cli": "catalog:", + "@rspack/core": "catalog:", + "ts-loader": "catalog:", + "typescript": "catalog:" + } +} diff --git a/packages/parser/rspack.config.js b/packages/parser/rspack.config.js new file mode 100644 index 0000000..8dd4a09 --- /dev/null +++ b/packages/parser/rspack.config.js @@ -0,0 +1,45 @@ +import { defineConfig } from "@rspack/cli"; + +const commonConfig = { + entry: { + index: "./src/index.ts", + }, + module: { + rules: [ + { + test: /\.ts$/, + use: "ts-loader", + exclude: /node_modules/, + }, + ], + }, + resolve: { + extensions: [".ts", ".js"], + alias: { + "@": "./src", + }, + }, +}; + +const esmConfig = defineConfig({ + ...commonConfig, + output: { + path: "./dist", + filename: "index.esm.js", + libraryTarget: "module", + }, + experiments: { + outputModule: true, + }, +}); + +const cjsConfig = defineConfig({ + ...commonConfig, + output: { + path: "./dist", + filename: "index.cjs.js", + libraryTarget: "commonjs2", + }, +}); + +export default [esmConfig, cjsConfig]; diff --git a/packages/parser/src/index.ts b/packages/parser/src/index.ts new file mode 100644 index 0000000..5c58fd8 --- /dev/null +++ b/packages/parser/src/index.ts @@ -0,0 +1 @@ +export * from "./parser"; diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts new file mode 100644 index 0000000..48649a0 --- /dev/null +++ b/packages/parser/src/parser.ts @@ -0,0 +1,7 @@ +export class DocutopiaParser { + constructor() {} + + parse() { + console.log("Parsing..."); + } +} diff --git a/packages/parser/tsconfig.json b/packages/parser/tsconfig.json new file mode 100644 index 0000000..32cf6fc --- /dev/null +++ b/packages/parser/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "ES6", + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "verbatimModuleSyntax": true, + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "allowSyntheticDefaultImports": true, + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "paths": { + "@/*": ["src/*"] + } + }, + "include": ["src/**/*.ts"], + "exclude": ["node_modules", "dist"] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a9ffa2a..3cd6398 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,18 +4,38 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +catalogs: + default: + '@biomejs/biome': + specifier: 1.8.3 + version: 1.8.3 + '@rspack/cli': + specifier: ^1.0.0 + version: 1.0.0 + '@rspack/core': + specifier: ^1.0.0 + version: 1.0.0 + ts-loader: + specifier: ^9.5.1 + version: 9.5.1 + typescript: + specifier: ^5.5.4 + version: 5.5.4 + importers: - .: + .: {} + + packages/core: devDependencies: '@biomejs/biome': - specifier: 1.8.3 + specifier: 'catalog:' version: 1.8.3 '@rspack/cli': - specifier: ^1.0.0 + specifier: 'catalog:' version: 1.0.0(@rspack/core@1.0.0)(@types/express@4.17.21)(webpack@5.94.0) '@rspack/core': - specifier: ^1.0.0 + specifier: 'catalog:' version: 1.0.0 serve: specifier: ^14.2.3 @@ -33,10 +53,28 @@ importers: specifier: ^6.0.2 version: 6.0.2(svelte@4.2.19)(typescript@5.5.4) ts-loader: - specifier: ^9.5.1 + specifier: 'catalog:' + version: 9.5.1(typescript@5.5.4)(webpack@5.94.0) + typescript: + specifier: 'catalog:' + version: 5.5.4 + + packages/parser: + devDependencies: + '@biomejs/biome': + specifier: 'catalog:' + version: 1.8.3 + '@rspack/cli': + specifier: 'catalog:' + version: 1.0.0(@rspack/core@1.0.0)(@types/express@4.17.21)(webpack@5.94.0) + '@rspack/core': + specifier: 'catalog:' + version: 1.0.0 + ts-loader: + specifier: 'catalog:' version: 9.5.1(typescript@5.5.4)(webpack@5.94.0) typescript: - specifier: ^5.5.4 + specifier: 'catalog:' version: 5.5.4 packages: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..6d3d00b --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,9 @@ +packages: + - 'packages/*' + +catalog: + '@biomejs/biome': 1.8.3 + typescript: ^5.5.4 + ts-loader: ^9.5.1 + '@rspack/cli': ^1.0.0 + '@rspack/core': ^1.0.0