From ac3e6e1cdadd6b5628ff673f6698f90f5c2db2f3 Mon Sep 17 00:00:00 2001 From: Andrew Courtice Date: Thu, 1 Dec 2022 12:16:31 +1000 Subject: [PATCH] feat: create unscoped harlem package --- app/package.json | 9 +- app/src/index.ts | 10 +- app/src/stores/app/store.ts | 2 +- app/vite.config.ts | 30 +++++- build.mjs | 141 ++++++++++++++++++++++++++ core/build.mjs | 3 + core/index.js | 5 + core/index.mjs | 1 + core/package.json | 30 ++++-- core/tsup.config.ts | 10 -- extensions/action/build.mjs | 3 + extensions/action/index.js | 5 + extensions/action/index.mjs | 1 + extensions/action/package.json | 30 ++++-- extensions/action/tsup.config.ts | 10 -- extensions/compose/build.mjs | 3 + extensions/compose/index.js | 5 + extensions/compose/index.mjs | 1 + extensions/compose/package.json | 30 ++++-- extensions/compose/tsup.config.ts | 10 -- extensions/history/build.mjs | 3 + extensions/history/index.js | 5 + extensions/history/index.mjs | 1 + extensions/history/package.json | 30 ++++-- extensions/history/tsup.config.ts | 10 -- extensions/lazy/build.mjs | 3 + extensions/lazy/index.js | 5 + extensions/lazy/index.mjs | 1 + extensions/lazy/package.json | 30 ++++-- extensions/lazy/tsup.config.ts | 10 -- extensions/reset/build.mjs | 3 + extensions/reset/index.js | 5 + extensions/reset/index.mjs | 1 + extensions/reset/package.json | 30 ++++-- extensions/reset/tsup.config.ts | 10 -- extensions/snapshot/build.mjs | 3 + extensions/snapshot/index.js | 5 + extensions/snapshot/index.mjs | 1 + extensions/snapshot/package.json | 30 ++++-- extensions/snapshot/tsup.config.ts | 10 -- extensions/storage/build.mjs | 3 + extensions/storage/index.js | 5 + extensions/storage/index.mjs | 1 + extensions/storage/package.json | 30 ++++-- extensions/storage/tsup.config.ts | 10 -- extensions/trace/build.mjs | 3 + extensions/trace/index.js | 5 + extensions/trace/index.mjs | 1 + extensions/trace/package.json | 30 ++++-- extensions/trace/tsup.config.ts | 10 -- extensions/transaction/build.mjs | 3 + extensions/transaction/index.js | 5 + extensions/transaction/index.mjs | 1 + extensions/transaction/package.json | 30 ++++-- extensions/transaction/tsup.config.ts | 10 -- global.d.ts | 3 +- harlem/README.md | 133 ++++++++++++++++++++++++ harlem/build.mjs | 3 + harlem/index.js | 5 + harlem/index.mjs | 1 + harlem/package.json | 59 +++++++++++ harlem/src/index.ts | 38 +++++++ harlem/tsconfig.json | 7 ++ lerna.json | 1 + package.json | 6 +- packages/task/build.mjs | 3 + packages/task/index.js | 5 + packages/task/index.mjs | 1 + packages/task/package.json | 30 ++++-- packages/task/tsup.config.ts | 10 -- packages/utilities/build.mjs | 3 + packages/utilities/index.js | 5 + packages/utilities/index.mjs | 1 + packages/utilities/package.json | 30 ++++-- packages/utilities/tsup.config.ts | 10 -- plugins/devtools/build.mjs | 3 + plugins/devtools/index.js | 5 + plugins/devtools/index.mjs | 1 + plugins/devtools/package.json | 30 ++++-- plugins/devtools/tsup.config.ts | 10 -- plugins/ssr/build.mjs | 3 + plugins/ssr/index.js | 5 + plugins/ssr/index.mjs | 1 + plugins/ssr/package.json | 30 ++++-- plugins/ssr/tsup.config.ts | 10 -- tsup.config.ts | 19 ---- yarn.lock | 54 +++++++++- 87 files changed, 873 insertions(+), 334 deletions(-) create mode 100644 build.mjs create mode 100644 core/build.mjs create mode 100644 core/index.js create mode 100644 core/index.mjs delete mode 100644 core/tsup.config.ts create mode 100644 extensions/action/build.mjs create mode 100644 extensions/action/index.js create mode 100644 extensions/action/index.mjs delete mode 100644 extensions/action/tsup.config.ts create mode 100644 extensions/compose/build.mjs create mode 100644 extensions/compose/index.js create mode 100644 extensions/compose/index.mjs delete mode 100644 extensions/compose/tsup.config.ts create mode 100644 extensions/history/build.mjs create mode 100644 extensions/history/index.js create mode 100644 extensions/history/index.mjs delete mode 100644 extensions/history/tsup.config.ts create mode 100644 extensions/lazy/build.mjs create mode 100644 extensions/lazy/index.js create mode 100644 extensions/lazy/index.mjs delete mode 100644 extensions/lazy/tsup.config.ts create mode 100644 extensions/reset/build.mjs create mode 100644 extensions/reset/index.js create mode 100644 extensions/reset/index.mjs delete mode 100644 extensions/reset/tsup.config.ts create mode 100644 extensions/snapshot/build.mjs create mode 100644 extensions/snapshot/index.js create mode 100644 extensions/snapshot/index.mjs delete mode 100644 extensions/snapshot/tsup.config.ts create mode 100644 extensions/storage/build.mjs create mode 100644 extensions/storage/index.js create mode 100644 extensions/storage/index.mjs delete mode 100644 extensions/storage/tsup.config.ts create mode 100644 extensions/trace/build.mjs create mode 100644 extensions/trace/index.js create mode 100644 extensions/trace/index.mjs delete mode 100644 extensions/trace/tsup.config.ts create mode 100644 extensions/transaction/build.mjs create mode 100644 extensions/transaction/index.js create mode 100644 extensions/transaction/index.mjs delete mode 100644 extensions/transaction/tsup.config.ts create mode 100644 harlem/README.md create mode 100644 harlem/build.mjs create mode 100644 harlem/index.js create mode 100644 harlem/index.mjs create mode 100644 harlem/package.json create mode 100644 harlem/src/index.ts create mode 100644 harlem/tsconfig.json create mode 100644 packages/task/build.mjs create mode 100644 packages/task/index.js create mode 100644 packages/task/index.mjs delete mode 100644 packages/task/tsup.config.ts create mode 100644 packages/utilities/build.mjs create mode 100644 packages/utilities/index.js create mode 100644 packages/utilities/index.mjs delete mode 100644 packages/utilities/tsup.config.ts create mode 100644 plugins/devtools/build.mjs create mode 100644 plugins/devtools/index.js create mode 100644 plugins/devtools/index.mjs delete mode 100644 plugins/devtools/tsup.config.ts create mode 100644 plugins/ssr/build.mjs create mode 100644 plugins/ssr/index.js create mode 100644 plugins/ssr/index.mjs delete mode 100644 plugins/ssr/tsup.config.ts delete mode 100644 tsup.config.ts diff --git a/app/package.json b/app/package.json index b17ad944..6fc2e4fd 100644 --- a/app/package.json +++ b/app/package.json @@ -9,11 +9,11 @@ "main": "src/index.ts", "scripts": { "start": "vite", - "serve": "vite preview", - "build": "vite build" + "build": "vite build", + "insights": "vite build --mode insights", + "serve": "vite build && vite preview" }, "dependencies": { - "@harlem/core": "^2.4.0-beta.1", "@harlem/extension-action": "^2.4.0-beta.1", "@harlem/extension-compose": "^2.4.0-beta.1", "@harlem/extension-history": "^2.4.0-beta.1", @@ -21,15 +21,16 @@ "@harlem/extension-storage": "^2.4.0-beta.1", "@harlem/extension-trace": "^2.4.0-beta.1", "@harlem/extension-transaction": "^2.4.0-beta.1", - "@harlem/plugin-devtools": "^2.4.0-beta.1", "date-fns": "^2.29.3", "date-fns-tz": "^1.3.7", "flex-layout-attribute": "^1.0.3", + "harlem": "^2.4.0-beta.1", "vue": "^3.2.45" }, "devDependencies": { "@vitejs/plugin-vue": "^3.2.0", "@vue/compiler-sfc": "^3.2.45", + "rollup-plugin-visualizer": "^5.8.3", "sass": "^1.56.1", "vite": "^3.2.4" } diff --git a/app/src/index.ts b/app/src/index.ts index 2ffa5621..f808fdf0 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -5,9 +5,7 @@ import App from './app.vue'; import { createVuePlugin, -} from '@harlem/core'; - -import devtoolsPlugin from '@harlem/plugin-devtools'; +} from 'harlem'; import { createApp, @@ -15,11 +13,7 @@ import { function start() { return createApp(App) - .use(createVuePlugin({ - plugins: [ - devtoolsPlugin(), - ], - })) + .use(createVuePlugin()) .mount('body'); } diff --git a/app/src/stores/app/store.ts b/app/src/stores/app/store.ts index 1278672f..5ea50e02 100644 --- a/app/src/stores/app/store.ts +++ b/app/src/stores/app/store.ts @@ -9,7 +9,7 @@ import { import { createStore, -} from '@harlem/core'; +} from 'harlem'; export const { state, diff --git a/app/vite.config.ts b/app/vite.config.ts index cf380e33..ae70b140 100644 --- a/app/vite.config.ts +++ b/app/vite.config.ts @@ -2,9 +2,14 @@ import vuePlugin from '@vitejs/plugin-vue'; import { defineConfig, + UserConfig, } from 'vite'; -export default defineConfig({ +import { + visualizer, +} from 'rollup-plugin-visualizer'; + +const BASE_CONFIG: UserConfig = { server: { port: 6565, }, @@ -24,4 +29,27 @@ export default defineConfig({ plugins: [ vuePlugin(), ], +}; + +export default defineConfig(({ mode }) => { + if (mode !== 'insights') { + return BASE_CONFIG; + } + + return { + ...BASE_CONFIG, + build: { + rollupOptions: { + plugins: [ + visualizer({ + filename: 'app.insights.html', + title: 'App Insights', + template: 'treemap', + open: true, + gzipSize: true, + }), + ], + }, + }, + }; }); \ No newline at end of file diff --git a/build.mjs b/build.mjs new file mode 100644 index 00000000..ff0af244 --- /dev/null +++ b/build.mjs @@ -0,0 +1,141 @@ +import path from 'path'; +import fse from 'fs-extra'; + +import { + build, +} from 'tsup'; + +import { + replace, +} from 'esbuild-plugin-replace'; + +/** + * @typedef Configuration + * @property {string} name + * @property {import('tsup').Options | (isProd: boolean) => import('tsup').Options} options + */ + +/** + * @type import('tsup').Options + */ +const baseOptions = { + target: 'es2018', + sourcemap: false, + clean: false, +}; + +/** + * @type Configuration[] + */ +const configurations = [ + { + name: 'commonjs', + options: isProd => ({ + format: ['cjs'], + minify: isProd, + outExtension: () => ({ + js: isProd ? '.cjs.prod.js' : '.cjs.js', + }), + esbuildPlugins: [ + replace({ + values: { + '__DEV__': isProd ? 'false' : 'process.env.NODE_ENV === "development"', + '__VUE_PROD_DEVTOOLS__': isProd ? 'false' : '(typeof __VUE_PROD_DEVTOOLS__ !== \'undefined\' && __VUE_PROD_DEVTOOLS__)', + }, + }), + ], + }), + }, + { + name: 'esm-bundler', + options: { + format: ['esm'], + outExtension: () => ({ + js: '.esm-bundler.js', + }), + esbuildPlugins: [ + replace({ + values: { + '__DEV__': 'process.env.NODE_ENV === "development"', + '__VUE_PROD_DEVTOOLS__': '(typeof __VUE_PROD_DEVTOOLS__ !== \'undefined\' && __VUE_PROD_DEVTOOLS__)', + }, + }), + ], + }, + }, + { + name: 'esm-browser', + options: isProd => ({ + format: ['esm'], + minify: isProd, + outExtension: () => ({ + js: isProd ? '.esm-browser.prod.js' : '.esm-browser.js', + }), + esbuildPlugins: [ + replace({ + values: { + '__DEV__': 'false', + '__VUE_PROD_DEVTOOLS__': 'false', + }, + }), + ], + }), + }, + { + name: 'global', + options: isProd => ({ + format: ['iife'], + minify: isProd, + outExtension: () => ({ + js: isProd ? '.global.prod.js' : '.global.js', + }), + esbuildPlugins: [ + replace({ + values: { + '__DEV__': `${!isProd}`, + '__VUE_PROD_DEVTOOLS__': `${!isProd}`, + }, + }), + ], + }), + }, + { + name: 'types', + options: { + dts: { + only: true, + }, + }, + }, +]; + +/** + * + * @param {string} cwd + * @param {string} entry + * @param {import('tsup').Options} options + */ +export default async function(cwd, entry, options) { + const entryFile = path.resolve(cwd, entry); + const outDir = path.resolve(cwd, './dist'); + + await fse.emptyDir(outDir); + + for (const { options: configuration } of configurations) { + const cfgOptions = typeof configuration === 'function' + ? [configuration(false), configuration(true)] + : [configuration]; + + for (const configOptions of cfgOptions) { + await build({ + ...baseOptions, + ...configOptions, + ...options, + outDir, + entry: [ + entryFile, + ], + }); + } + } +} \ No newline at end of file diff --git a/core/build.mjs b/core/build.mjs new file mode 100644 index 00000000..9b84fe6c --- /dev/null +++ b/core/build.mjs @@ -0,0 +1,3 @@ +import build from '../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/core/index.js b/core/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/core/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/core/index.mjs b/core/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/core/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/core/package.json b/core/package.json index 3c13e744..e05e5a07 100644 --- a/core/package.json +++ b/core/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "Powerfully simple global state management for Vue 3", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -34,8 +43,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "dependencies": { diff --git a/core/tsup.config.ts b/core/tsup.config.ts deleted file mode 100644 index b7f19492..00000000 --- a/core/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'Harlem', -} as Options; \ No newline at end of file diff --git a/extensions/action/build.mjs b/extensions/action/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/action/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/action/index.js b/extensions/action/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/action/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/action/index.mjs b/extensions/action/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/action/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/action/package.json b/extensions/action/package.json index e5a9f056..99f5b93b 100644 --- a/extensions/action/package.json +++ b/extensions/action/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official action extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "dependencies": { diff --git a/extensions/action/tsup.config.ts b/extensions/action/tsup.config.ts deleted file mode 100644 index 6ca54951..00000000 --- a/extensions/action/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemActionExtension', -} as Options; \ No newline at end of file diff --git a/extensions/compose/build.mjs b/extensions/compose/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/compose/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/compose/index.js b/extensions/compose/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/compose/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/compose/index.mjs b/extensions/compose/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/compose/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/compose/package.json b/extensions/compose/package.json index fca09730..383d78bb 100644 --- a/extensions/compose/package.json +++ b/extensions/compose/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official compose extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "dependencies": { diff --git a/extensions/compose/tsup.config.ts b/extensions/compose/tsup.config.ts deleted file mode 100644 index a01c8a69..00000000 --- a/extensions/compose/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemComposeExtension', -} as Options; \ No newline at end of file diff --git a/extensions/history/build.mjs b/extensions/history/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/history/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/history/index.js b/extensions/history/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/history/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/history/index.mjs b/extensions/history/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/history/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/history/package.json b/extensions/history/package.json index 7a7270c3..204332f6 100644 --- a/extensions/history/package.json +++ b/extensions/history/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official history extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "dependencies": { diff --git a/extensions/history/tsup.config.ts b/extensions/history/tsup.config.ts deleted file mode 100644 index cd5365aa..00000000 --- a/extensions/history/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemHistoryExtension', -} as Options; \ No newline at end of file diff --git a/extensions/lazy/build.mjs b/extensions/lazy/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/lazy/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/lazy/index.js b/extensions/lazy/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/lazy/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/lazy/index.mjs b/extensions/lazy/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/lazy/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/lazy/package.json b/extensions/lazy/package.json index 8f75338b..2d9597d6 100644 --- a/extensions/lazy/package.json +++ b/extensions/lazy/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official lazy extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "peerDependencies": { diff --git a/extensions/lazy/tsup.config.ts b/extensions/lazy/tsup.config.ts deleted file mode 100644 index c8bef15d..00000000 --- a/extensions/lazy/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemLazyExtension', -} as Options; \ No newline at end of file diff --git a/extensions/reset/build.mjs b/extensions/reset/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/reset/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/reset/index.js b/extensions/reset/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/reset/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/reset/index.mjs b/extensions/reset/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/reset/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/reset/package.json b/extensions/reset/package.json index cb351737..a4fd6639 100644 --- a/extensions/reset/package.json +++ b/extensions/reset/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official reset extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "peerDependencies": { diff --git a/extensions/reset/tsup.config.ts b/extensions/reset/tsup.config.ts deleted file mode 100644 index e1e517d7..00000000 --- a/extensions/reset/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemResetExtension', -} as Options; \ No newline at end of file diff --git a/extensions/snapshot/build.mjs b/extensions/snapshot/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/snapshot/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/snapshot/index.js b/extensions/snapshot/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/snapshot/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/snapshot/index.mjs b/extensions/snapshot/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/snapshot/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/snapshot/package.json b/extensions/snapshot/package.json index b8885a12..2372b22c 100644 --- a/extensions/snapshot/package.json +++ b/extensions/snapshot/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official snapshot extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "peerDependencies": { diff --git a/extensions/snapshot/tsup.config.ts b/extensions/snapshot/tsup.config.ts deleted file mode 100644 index 3f2f7457..00000000 --- a/extensions/snapshot/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemSnapshotExtension', -} as Options; \ No newline at end of file diff --git a/extensions/storage/build.mjs b/extensions/storage/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/storage/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/storage/index.js b/extensions/storage/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/storage/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/storage/index.mjs b/extensions/storage/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/storage/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/storage/package.json b/extensions/storage/package.json index 4f5c6521..eff4b48d 100644 --- a/extensions/storage/package.json +++ b/extensions/storage/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official storage extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "dependencies": { diff --git a/extensions/storage/tsup.config.ts b/extensions/storage/tsup.config.ts deleted file mode 100644 index 240f599f..00000000 --- a/extensions/storage/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemStorageExtension', -} as Options; \ No newline at end of file diff --git a/extensions/trace/build.mjs b/extensions/trace/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/trace/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/trace/index.js b/extensions/trace/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/trace/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/trace/index.mjs b/extensions/trace/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/trace/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/trace/package.json b/extensions/trace/package.json index 4c44fb94..83878ee3 100644 --- a/extensions/trace/package.json +++ b/extensions/trace/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official trace extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "peerDependencies": { diff --git a/extensions/trace/tsup.config.ts b/extensions/trace/tsup.config.ts deleted file mode 100644 index cecbb715..00000000 --- a/extensions/trace/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemTraceExtension', -} as Options; \ No newline at end of file diff --git a/extensions/transaction/build.mjs b/extensions/transaction/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/extensions/transaction/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/extensions/transaction/index.js b/extensions/transaction/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/extensions/transaction/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/extensions/transaction/index.mjs b/extensions/transaction/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/extensions/transaction/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/extensions/transaction/package.json b/extensions/transaction/package.json index d59bf6ac..9f073f6f 100644 --- a/extensions/transaction/package.json +++ b/extensions/transaction/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official transaction extension for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "peerDependencies": { diff --git a/extensions/transaction/tsup.config.ts b/extensions/transaction/tsup.config.ts deleted file mode 100644 index d6980ab0..00000000 --- a/extensions/transaction/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemTransactionExtension', -} as Options; \ No newline at end of file diff --git a/global.d.ts b/global.d.ts index b8c18cc6..c21cbe02 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1 +1,2 @@ -declare const __DEV__: boolean; \ No newline at end of file +declare const __DEV__: boolean; +declare const __VUE_PROD_DEVTOOLS__: boolean; \ No newline at end of file diff --git a/harlem/README.md b/harlem/README.md new file mode 100644 index 00000000..1c0053ed --- /dev/null +++ b/harlem/README.md @@ -0,0 +1,133 @@ +

+ + Harlem + +

+ +# Harlem + +![npm](https://img.shields.io/npm/v/@harlem/core) + +This is the core Harlem package. For a general overview of Harlem see [here](https://github.com/andrewcourtice/harlem) or check out the [complete documentation](https://harlemjs.com/). + + +## Getting started + +1. Install `@harlem/core`: +```bash +yarn add @harlem/core +# or +npm install @harlem/core +``` + +2. Register the Harlem plugin with your Vue app instance: +```typescript +import App from './app.vue'; +import Harlem from '@harlem/core'; + +createApp(App) + .use(Harlem) + .mount('#app'); +``` + +3. Create your store and write any getters, mutations or actions (if using the actions extension): +```typescript +import { + createStore +} from '@harlem/core'; + +const STATE = { + firstName: 'John', + lastName: 'Smith' +}; + +const { + getter, + mutation, + ...store +} = createStore('user', STATE); + +export const state = store.state; +export const fullName = getter('fullname', state => `${state.firstName} ${state.lastName}`); +export const setFirstName = mutation('set-first-name', (state, payload) => state.firstName = payload); +export const setLastName = mutation('set-last-name', (state, payload) => state.lastName = payload); +``` + +Or if you're using actions: + +```typescript +import actionExtension from '@harlem/extension-action'; + +import { + createStore +} from '@harlem/core'; + +const STATE = { + firstName: 'John', + lastName: 'Smith' +}; + +export const { + state, + getter, + mutation, + action, + ...store +} = createStore('user', STATE, { + extensions: [ + actionExtension() + ] +}); + +export const fullName = getter('fullname', state => { + return `${state.firstName} ${state.lastName}`; +}); + +export const loadUserData = action('load-user-data', async (id: string, mutate, { signal }) => { + const response = await fetch(`/api/users/${id}`, { signal }); + + const { + firstName, + lastName, + } = await response.json(); + + mutate(state => { + state.firstName = firstName; + state.lastName = lastName; + }); +}); +``` + +4. Use your store in your app: +```html + + + +``` \ No newline at end of file diff --git a/harlem/build.mjs b/harlem/build.mjs new file mode 100644 index 00000000..9b84fe6c --- /dev/null +++ b/harlem/build.mjs @@ -0,0 +1,3 @@ +import build from '../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/harlem/index.js b/harlem/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/harlem/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/harlem/index.mjs b/harlem/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/harlem/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/harlem/package.json b/harlem/package.json new file mode 100644 index 00000000..e64d936d --- /dev/null +++ b/harlem/package.json @@ -0,0 +1,59 @@ +{ + "name": "harlem", + "amdName": "harlem", + "version": "2.4.0-beta.8", + "license": "MIT", + "author": "Andrew Courtice ", + "description": "Powerfully simple global state management for Vue 3", + "homepage": "https://harlemjs.com", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", + "unpkg": "dist/index.global.js", + "jsdelivr": "dist/index.global.js", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], + "exports": { + ".": { + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" + }, + "keywords": [ + "vue", + "state", + "harlem" + ], + "repository": { + "type": "git", + "url": "https://github.com/andrewcourtice/harlem.git", + "directory": "core" + }, + "bugs": { + "url": "https://github.com/andrewcourtice/harlem/issues" + }, + "scripts": { + "build": "node ./build.mjs", + "prepublishOnly": "yarn build" + }, + "dependencies": { + "@harlem/core": "^2.4.0-beta.8", + "@harlem/plugin-devtools": "^2.4.0-beta.8" + }, + "peerDependencies": { + "vue": "^3.2.0" + }, + "devDependencies": { + "vue": "^3.2.45" + } +} diff --git a/harlem/src/index.ts b/harlem/src/index.ts new file mode 100644 index 00000000..3d20f6b0 --- /dev/null +++ b/harlem/src/index.ts @@ -0,0 +1,38 @@ +import devtoolsPlugin from '@harlem/plugin-devtools'; + +import { + createInstance as _createInstance, + createVuePlugin as _createVuePlugin, + HarlemOptions, +} from '@harlem/core'; + +export * from '@harlem/core'; + +function wrapCreatePlugin(func: typeof _createVuePlugin) { + return (options?: HarlemOptions) => { + const plugins = options?.plugins || []; + + if (__DEV__ || __VUE_PROD_DEVTOOLS__) { + plugins.push(devtoolsPlugin()); + } + + return func({ + ...options, + plugins, + }); + }; +} + +export const createVuePlugin = wrapCreatePlugin(_createVuePlugin); + +export function createInstance(): ReturnType { + const { + createVuePlugin, + ...instance + } = _createInstance(); + + return { + ...instance, + createVuePlugin: wrapCreatePlugin(createVuePlugin), + }; +} \ No newline at end of file diff --git a/harlem/tsconfig.json b/harlem/tsconfig.json new file mode 100644 index 00000000..9850db0a --- /dev/null +++ b/harlem/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.json", + "include": [ + "src/**/*.ts", + "../global.d.ts" + ] +} \ No newline at end of file diff --git a/lerna.json b/lerna.json index eea26c4c..10fb1ad6 100644 --- a/lerna.json +++ b/lerna.json @@ -4,6 +4,7 @@ "useWorkspaces": true, "packages": [ "core", + "harlem", "packages/*", "extensions/*", "plugins/*" diff --git a/package.json b/package.json index c4d95a53..fb9a1f7c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "harlem", + "name": "harlem-workspace", "version": "1.0.0", "description": "Powerfully simple global state management for Vue 3", "repository": "https://github.com/andrewcourtice/harlem.git", @@ -11,6 +11,7 @@ "app", "core", "docs", + "harlem", "examples/*", "packages/*", "extensions/*", @@ -28,12 +29,15 @@ "devDependencies": { "@commitlint/cli": "^17.2.0", "@commitlint/config-conventional": "^17.2.0", + "@types/fs-extra": "^9.0.13", "@typescript-eslint/eslint-plugin": "^5.43.0", "@typescript-eslint/parser": "^5.43.0", "@vitest/coverage-c8": "^0.25.2", "c8": "^7.12.0", + "esbuild-plugin-replace": "^1.3.0", "eslint": "^8.28.0", "eslint-plugin-vue": "^9.7.0", + "fs-extra": "^11.1.0", "husky": "^8.0.2", "jsdom": "^20.0.3", "lerna": "^6.0.3", diff --git a/packages/task/build.mjs b/packages/task/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/packages/task/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/packages/task/index.js b/packages/task/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/packages/task/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/packages/task/index.mjs b/packages/task/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/packages/task/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/packages/task/package.json b/packages/task/package.json index c225a307..a634a98f 100644 --- a/packages/task/package.json +++ b/packages/task/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "Harlem task package", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -35,8 +44,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" } } diff --git a/packages/task/tsup.config.ts b/packages/task/tsup.config.ts deleted file mode 100644 index 8808cd3d..00000000 --- a/packages/task/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemUtilities', -} as Options; \ No newline at end of file diff --git a/packages/utilities/build.mjs b/packages/utilities/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/packages/utilities/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/packages/utilities/index.js b/packages/utilities/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/packages/utilities/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/packages/utilities/index.mjs b/packages/utilities/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/packages/utilities/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/packages/utilities/package.json b/packages/utilities/package.json index d1a84a8e..e26f03fe 100644 --- a/packages/utilities/package.json +++ b/packages/utilities/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "Harlem utilities package", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -35,8 +44,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "peerDependencies": { diff --git a/packages/utilities/tsup.config.ts b/packages/utilities/tsup.config.ts deleted file mode 100644 index 8808cd3d..00000000 --- a/packages/utilities/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemUtilities', -} as Options; \ No newline at end of file diff --git a/plugins/devtools/build.mjs b/plugins/devtools/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/plugins/devtools/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/plugins/devtools/index.js b/plugins/devtools/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/plugins/devtools/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/plugins/devtools/index.mjs b/plugins/devtools/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/plugins/devtools/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/plugins/devtools/package.json b/plugins/devtools/package.json index 2534e441..5e4ee9f7 100644 --- a/plugins/devtools/package.json +++ b/plugins/devtools/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official Vue devtools plugin for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "peerDependencies": { diff --git a/plugins/devtools/tsup.config.ts b/plugins/devtools/tsup.config.ts deleted file mode 100644 index de0a0ed4..00000000 --- a/plugins/devtools/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemDevtoolsPlugin', -} as Options; \ No newline at end of file diff --git a/plugins/ssr/build.mjs b/plugins/ssr/build.mjs new file mode 100644 index 00000000..7e3a179d --- /dev/null +++ b/plugins/ssr/build.mjs @@ -0,0 +1,3 @@ +import build from '../../build.mjs'; + +build(process.cwd(), './src/index.ts'); \ No newline at end of file diff --git a/plugins/ssr/index.js b/plugins/ssr/index.js new file mode 100644 index 00000000..364f637e --- /dev/null +++ b/plugins/ssr/index.js @@ -0,0 +1,5 @@ +if (process.env.NODE_ENV === 'production') { + return require('./dist/index.cjs.prod.js'); +} else { + return require('./dist/index.cjs.js'); +} \ No newline at end of file diff --git a/plugins/ssr/index.mjs b/plugins/ssr/index.mjs new file mode 100644 index 00000000..833b6a2f --- /dev/null +++ b/plugins/ssr/index.mjs @@ -0,0 +1 @@ +export * from './index.js'; \ No newline at end of file diff --git a/plugins/ssr/package.json b/plugins/ssr/package.json index 2f277260..fda2448e 100644 --- a/plugins/ssr/package.json +++ b/plugins/ssr/package.json @@ -6,19 +6,28 @@ "author": "Andrew Courtice ", "description": "The official server-side rendering plugin for Harlem", "homepage": "https://harlemjs.com", - "source": "src/index.ts", - "main": "dist/index.js", - "module": "dist/index.mjs", + "main": "index.js", + "module": "dist/index.esm-bundler.js", + "types": "dist/index.d.ts", "unpkg": "dist/index.global.js", "jsdelivr": "dist/index.global.js", - "types": "dist/index.d.ts", + "sideEffects": false, + "files": [ + "dist", + "index.js", + "index.mjs" + ], "exports": { - "./package.json": "./package.json", ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } + "import": { + "node": "./index.mjs", + "default": "./dist/index.esm-bundler.js" + }, + "require": "./index.js", + "types": "./dist/index.d.ts" + }, + "./dist/*": "./dist/*", + "./package.json": "./package.json" }, "keywords": [ "vue", @@ -36,8 +45,7 @@ "url": "https://github.com/andrewcourtice/harlem/issues" }, "scripts": { - "dev": "yarn run --top-level tsup --watch src", - "build": "yarn run --top-level tsup", + "build": "node ./build.mjs", "prepublishOnly": "yarn build" }, "peerDependencies": { diff --git a/plugins/ssr/tsup.config.ts b/plugins/ssr/tsup.config.ts deleted file mode 100644 index 66caff6d..00000000 --- a/plugins/ssr/tsup.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import base from '../../tsup.config'; - -import type { - Options, -} from 'tsup'; - -export default { - ...base, - globalName: 'HarlemSSRPlugin', -} as Options; \ No newline at end of file diff --git a/tsup.config.ts b/tsup.config.ts deleted file mode 100644 index a6707022..00000000 --- a/tsup.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { - Options, -} from 'tsup'; - -export default { - clean: true, - dts: true, - sourcemap: true, - target: 'es2018', - format: [ - 'esm', - 'cjs', - 'iife', - ], - entryPoints: [ - './src/index.ts', - ], - outDir: './dist', -} as Options; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 42c7af55..ddd371d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -811,7 +811,6 @@ __metadata: version: 0.0.0-use.local resolution: "@harlem/app@workspace:app" dependencies: - "@harlem/core": ^2.4.0-beta.1 "@harlem/extension-action": ^2.4.0-beta.1 "@harlem/extension-compose": ^2.4.0-beta.1 "@harlem/extension-history": ^2.4.0-beta.1 @@ -819,12 +818,13 @@ __metadata: "@harlem/extension-storage": ^2.4.0-beta.1 "@harlem/extension-trace": ^2.4.0-beta.1 "@harlem/extension-transaction": ^2.4.0-beta.1 - "@harlem/plugin-devtools": ^2.4.0-beta.1 "@vitejs/plugin-vue": ^3.2.0 "@vue/compiler-sfc": ^3.2.45 date-fns: ^2.29.3 date-fns-tz: ^1.3.7 flex-layout-attribute: ^1.0.3 + harlem: ^2.4.0-beta.1 + rollup-plugin-visualizer: ^5.8.3 sass: ^1.56.1 vite: ^3.2.4 vue: ^3.2.45 @@ -1015,7 +1015,7 @@ __metadata: languageName: unknown linkType: soft -"@harlem/plugin-devtools@^2.4.0-beta.1, @harlem/plugin-devtools@workspace:plugins/devtools": +"@harlem/plugin-devtools@^2.4.0-beta.1, @harlem/plugin-devtools@^2.4.0-beta.8, @harlem/plugin-devtools@workspace:plugins/devtools": version: 0.0.0-use.local resolution: "@harlem/plugin-devtools@workspace:plugins/devtools" dependencies: @@ -2773,6 +2773,15 @@ __metadata: languageName: node linkType: hard +"@types/fs-extra@npm:^9.0.13": + version: 9.0.13 + resolution: "@types/fs-extra@npm:9.0.13" + dependencies: + "@types/node": "*" + checksum: add79e212acd5ac76b97b9045834e03a7996aef60a814185e0459088fd290519a3c1620865d588fa36c4498bf614210d2a703af5cf80aa1dbc125db78f6edac3 + languageName: node + linkType: hard + "@types/istanbul-lib-coverage@npm:^2.0.1": version: 2.0.4 resolution: "@types/istanbul-lib-coverage@npm:2.0.4" @@ -5729,6 +5738,15 @@ __metadata: languageName: node linkType: hard +"esbuild-plugin-replace@npm:^1.3.0": + version: 1.3.0 + resolution: "esbuild-plugin-replace@npm:1.3.0" + dependencies: + magic-string: ^0.25.7 + checksum: 08ce149e1850eb3f1ac16cc6adc345d8198ccf3a84982239de67a34540da282b85c586ad29d59c49ad5561c173fe451574eceafb23104c182090202593d74820 + languageName: node + linkType: hard + "esbuild-sunos-64@npm:0.14.54": version: 0.14.54 resolution: "esbuild-sunos-64@npm:0.14.54" @@ -6498,6 +6516,17 @@ __metadata: languageName: node linkType: hard +"fs-extra@npm:^11.1.0": + version: 11.1.0 + resolution: "fs-extra@npm:11.1.0" + dependencies: + graceful-fs: ^4.2.0 + jsonfile: ^6.0.1 + universalify: ^2.0.0 + checksum: 5ca476103fa1f5ff4a9b3c4f331548f8a3c1881edaae323a4415d3153b5dc11dc6a981c8d1dd93eec8367ceee27b53f8bd27eecbbf66ffcdd04927510c171e7f + languageName: node + linkType: hard + "fs-extra@npm:^9.1.0": version: 9.1.0 resolution: "fs-extra@npm:9.1.0" @@ -6926,18 +6955,21 @@ __metadata: languageName: node linkType: hard -"harlem@workspace:.": +"harlem-workspace@workspace:.": version: 0.0.0-use.local - resolution: "harlem@workspace:." + resolution: "harlem-workspace@workspace:." dependencies: "@commitlint/cli": ^17.2.0 "@commitlint/config-conventional": ^17.2.0 + "@types/fs-extra": ^9.0.13 "@typescript-eslint/eslint-plugin": ^5.43.0 "@typescript-eslint/parser": ^5.43.0 "@vitest/coverage-c8": ^0.25.2 c8: ^7.12.0 + esbuild-plugin-replace: ^1.3.0 eslint: ^8.28.0 eslint-plugin-vue: ^9.7.0 + fs-extra: ^11.1.0 husky: ^8.0.2 jsdom: ^20.0.3 lerna: ^6.0.3 @@ -6951,6 +6983,18 @@ __metadata: languageName: unknown linkType: soft +"harlem@^2.4.0-beta.1, harlem@workspace:harlem": + version: 0.0.0-use.local + resolution: "harlem@workspace:harlem" + dependencies: + "@harlem/core": ^2.4.0-beta.8 + "@harlem/plugin-devtools": ^2.4.0-beta.8 + vue: ^3.2.45 + peerDependencies: + vue: ^3.2.0 + languageName: unknown + linkType: soft + "has-flag@npm:^3.0.0": version: 3.0.0 resolution: "has-flag@npm:3.0.0"