-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create unscoped harlem package
- Loading branch information
1 parent
248457d
commit ac3e6e1
Showing
87 changed files
with
873 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { | |
|
||
import { | ||
createStore, | ||
} from '@harlem/core'; | ||
} from 'harlem'; | ||
|
||
export const { | ||
state, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
], | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import build from '../build.mjs'; | ||
|
||
build(process.cwd(), './src/index.ts'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if (process.env.NODE_ENV === 'production') { | ||
return require('./dist/index.cjs.prod.js'); | ||
} else { | ||
return require('./dist/index.cjs.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,28 @@ | |
"author": "Andrew Courtice <[email protected]>", | ||
"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": { | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import build from '../../build.mjs'; | ||
|
||
build(process.cwd(), './src/index.ts'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if (process.env.NODE_ENV === 'production') { | ||
return require('./dist/index.cjs.prod.js'); | ||
} else { | ||
return require('./dist/index.cjs.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,28 @@ | |
"author": "Andrew Courtice <[email protected]>", | ||
"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": { | ||
|
Oops, something went wrong.