Theatric - a leva-like Theatre.js API for React (#375)
Co-authored-by: Aria Minaei <aria.minaei@gmail.com>
This commit is contained in:
parent
2efd9e9c7a
commit
246e75ccb5
17 changed files with 794 additions and 10 deletions
36
packages/theatric/devEnv/api-extractor.json
Normal file
36
packages/theatric/devEnv/api-extractor.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
|
||||
*/
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
|
||||
/**
|
||||
* Optionally specifies another JSON config file that this file extends from. This provides a way for
|
||||
* standard settings to be shared across multiple projects.
|
||||
*
|
||||
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
|
||||
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
|
||||
* resolved using NodeJS require().
|
||||
*
|
||||
* SUPPORTED TOKENS: none
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
"extends": "../../../devEnv/api-extractor-base.json",
|
||||
// "extends": "my-package/include/api-extractor-base.json"
|
||||
|
||||
/**
|
||||
* Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
|
||||
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting.
|
||||
*
|
||||
* The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
|
||||
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
|
||||
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
|
||||
* will be reported.
|
||||
*
|
||||
* SUPPORTED TOKENS: <lookup>
|
||||
* DEFAULT VALUE: "<lookup>"
|
||||
*/
|
||||
"projectFolder": ".."
|
||||
}
|
7
packages/theatric/devEnv/api-extractor.tsconfig.json
Normal file
7
packages/theatric/devEnv/api-extractor.tsconfig.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"paths": {}
|
||||
}
|
||||
}
|
55
packages/theatric/devEnv/build.ts
Normal file
55
packages/theatric/devEnv/build.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
import * as path from 'path'
|
||||
import {build} from 'esbuild'
|
||||
import type {Plugin} from 'esbuild'
|
||||
|
||||
const externalPlugin = (patterns: RegExp[]): Plugin => {
|
||||
return {
|
||||
name: `external`,
|
||||
|
||||
setup(build) {
|
||||
build.onResolve({filter: /.*/}, (args) => {
|
||||
const external = patterns.some((p) => {
|
||||
return p.test(args.path)
|
||||
})
|
||||
|
||||
if (external) {
|
||||
return {path: args.path, external}
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const definedGlobals = {
|
||||
global: 'window',
|
||||
}
|
||||
|
||||
function createBundles(watch: boolean) {
|
||||
const pathToPackage = path.join(__dirname, '../')
|
||||
const esbuildConfig: Parameters<typeof build>[0] = {
|
||||
entryPoints: [path.join(pathToPackage, 'src/index.ts')],
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
define: definedGlobals,
|
||||
watch,
|
||||
platform: 'neutral',
|
||||
mainFields: ['browser', 'module', 'main'],
|
||||
target: ['firefox57', 'chrome58'],
|
||||
conditions: ['browser', 'node'],
|
||||
plugins: [externalPlugin([/^[\@a-zA-Z]+/])],
|
||||
}
|
||||
|
||||
build({
|
||||
...esbuildConfig,
|
||||
outfile: path.join(pathToPackage, 'dist/index.js'),
|
||||
format: 'cjs',
|
||||
})
|
||||
|
||||
// build({
|
||||
// ...esbuildConfig,
|
||||
// outfile: path.join(pathToPackage, 'dist/index.mjs'),
|
||||
// format: 'esm',
|
||||
// })
|
||||
}
|
||||
|
||||
createBundles(false)
|
3
packages/theatric/devEnv/tsconfig.json
Normal file
3
packages/theatric/devEnv/tsconfig.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue