Skip to content

Commit

Permalink
fix: fixed build and publish configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcourtice committed Dec 1, 2022
1 parent 9465580 commit 5eaaade
Show file tree
Hide file tree
Showing 36 changed files with 146 additions and 169 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start": "vite",
"build": "vite build",
"insights": "vite build --mode insights",
"serve": "vite build && vite preview"
"preview": "vite build && vite preview"
},
"dependencies": {
"@harlem/extension-action": "^2.4.0-beta.1",
Expand Down
40 changes: 24 additions & 16 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import {
* @property {import('tsup').Options | (isProd: boolean) => import('tsup').Options} options
*/

/**
* Shims used to replace global constants
*/
const SHIMS = {
devEnv: 'process.env.NODE_ENV === "development"',
prodDevtools: '(typeof __VUE_PROD_DEVTOOLS__ !== \'undefined\' && __VUE_PROD_DEVTOOLS__)',
};

/**
* @type import('tsup').Options
*/
Expand All @@ -27,20 +35,20 @@ const baseOptions = {
/**
* @type Configuration[]
*/
const configurations = [
const builds = [
{
name: 'commonjs',
options: isProd => ({
format: ['cjs'],
minify: isProd,
outExtension: () => ({
js: isProd ? '.cjs.prod.js' : '.cjs.js',
js: isProd ? '.prod.cjs' : '.cjs',
}),
esbuildPlugins: [
replace({
values: {
'__DEV__': isProd ? 'false' : 'process.env.NODE_ENV === "development"',
'__VUE_PROD_DEVTOOLS__': isProd ? 'false' : '(typeof __VUE_PROD_DEVTOOLS__ !== \'undefined\' && __VUE_PROD_DEVTOOLS__)',
'__DEV__': isProd ? 'false' : SHIMS.devEnv,
'__VUE_PROD_DEVTOOLS__': isProd ? 'false' : SHIMS.prodDevtools,
},
}),
],
Expand All @@ -51,13 +59,13 @@ const configurations = [
options: {
format: ['esm'],
outExtension: () => ({
js: '.esm-bundler.js',
js: '.bundler.mjs',
}),
esbuildPlugins: [
replace({
values: {
'__DEV__': 'process.env.NODE_ENV === "development"',
'__VUE_PROD_DEVTOOLS__': '(typeof __VUE_PROD_DEVTOOLS__ !== \'undefined\' && __VUE_PROD_DEVTOOLS__)',
'__DEV__': SHIMS.devEnv,
'__VUE_PROD_DEVTOOLS__': SHIMS.prodDevtools,
},
}),
],
Expand All @@ -69,7 +77,7 @@ const configurations = [
format: ['esm'],
minify: isProd,
outExtension: () => ({
js: isProd ? '.esm-browser.prod.js' : '.esm-browser.js',
js: isProd ? '.browser.prod.mjs' : '.browser.mjs',
}),
esbuildPlugins: [
replace({
Expand All @@ -82,12 +90,12 @@ const configurations = [
}),
},
{
name: 'global',
name: 'iife',
options: isProd => ({
format: ['iife'],
minify: isProd,
outExtension: () => ({
js: isProd ? '.global.prod.js' : '.global.js',
js: isProd ? '.iife.prod.js' : '.iife.js',
}),
esbuildPlugins: [
replace({
Expand Down Expand Up @@ -121,15 +129,15 @@ export default async function(cwd, entry, options) {

await fse.emptyDir(outDir);

for (const { options: configuration } of configurations) {
const cfgOptions = typeof configuration === 'function'
? [configuration(false), configuration(true)]
: [configuration];
for (const { options: buildOptions } of builds) {
const resolvedOptionSets = typeof buildOptions === 'function'
? [buildOptions(false), buildOptions(true)]
: [buildOptions];

for (const configOptions of cfgOptions) {
for (const resolvedOptions of resolvedOptionSets) {
await build({
...baseOptions,
...configOptions,
...resolvedOptions,
...options,
outDir,
entry: [
Expand Down
1 change: 0 additions & 1 deletion core/index.mjs

This file was deleted.

16 changes: 6 additions & 10 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "Powerfully simple global state management for Vue 3",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down Expand Up @@ -55,4 +51,4 @@
"devDependencies": {
"vue": "^3.2.45"
}
}
}
1 change: 0 additions & 1 deletion extensions/action/index.mjs

This file was deleted.

14 changes: 5 additions & 9 deletions extensions/action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "The official action extension for Harlem",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down
1 change: 0 additions & 1 deletion extensions/compose/index.mjs

This file was deleted.

14 changes: 5 additions & 9 deletions extensions/compose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "The official compose extension for Harlem",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down
1 change: 0 additions & 1 deletion extensions/history/index.mjs

This file was deleted.

14 changes: 5 additions & 9 deletions extensions/history/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "The official history extension for Harlem",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down
1 change: 0 additions & 1 deletion extensions/lazy/index.mjs

This file was deleted.

14 changes: 5 additions & 9 deletions extensions/lazy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "The official lazy extension for Harlem",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down
1 change: 0 additions & 1 deletion extensions/reset/index.mjs

This file was deleted.

14 changes: 5 additions & 9 deletions extensions/reset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "The official reset extension for Harlem",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down
1 change: 0 additions & 1 deletion extensions/snapshot/index.mjs

This file was deleted.

14 changes: 5 additions & 9 deletions extensions/snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "The official snapshot extension for Harlem",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down
1 change: 0 additions & 1 deletion extensions/storage/index.mjs

This file was deleted.

14 changes: 5 additions & 9 deletions extensions/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "The official storage extension for Harlem",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down
1 change: 0 additions & 1 deletion extensions/trace/index.mjs

This file was deleted.

14 changes: 5 additions & 9 deletions extensions/trace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"description": "The official trace extension for Harlem",
"homepage": "https://harlemjs.com",
"main": "index.js",
"module": "dist/index.esm-bundler.js",
"module": "dist/index.bundler.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.iife.js",
"jsdelivr": "dist/index.iife.js",
"sideEffects": false,
"files": [
"dist",
"index.js",
"index.mjs"
"index.js"
],
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/index.esm-bundler.js"
},
"import": "./dist/index.bundler.mjs",
"require": "./index.js",
"types": "./dist/index.d.ts"
},
Expand Down
Loading

0 comments on commit 5eaaade

Please sign in to comment.