Build: Add a commonjs bundle to dataverse
This commit is contained in:
parent
90d26ecd32
commit
14b3207680
9 changed files with 65 additions and 7 deletions
|
@ -23,7 +23,11 @@ module.exports = {
|
|||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint'],
|
||||
parserOptions: {
|
||||
project: ['./packages/**/tsconfig.json', './theatre/**/tsconfig.json'],
|
||||
project: [
|
||||
'./packages/*/tsconfig.json',
|
||||
'./packages/*/devEnv/tsconfig.json',
|
||||
'./theatre/*/tsconfig.json',
|
||||
],
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/await-thenable': 'warn',
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
module.exports = {}
|
35
packages/dataverse/devEnv/build.ts
Normal file
35
packages/dataverse/devEnv/build.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import path from 'path'
|
||||
import {build} from 'esbuild'
|
||||
|
||||
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'],
|
||||
}
|
||||
|
||||
build({
|
||||
...esbuildConfig,
|
||||
outfile: path.join(pathToPackage, 'dist/index.cjs'),
|
||||
format: 'cjs',
|
||||
})
|
||||
|
||||
build({
|
||||
...esbuildConfig,
|
||||
outfile: path.join(pathToPackage, 'dist/index.mjs'),
|
||||
format: 'esm',
|
||||
})
|
||||
}
|
||||
|
||||
createBundles(false)
|
3
packages/dataverse/devEnv/tsconfig.json
Normal file
3
packages/dataverse/devEnv/tsconfig.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
|
||||
}
|
|
@ -12,20 +12,34 @@
|
|||
"url": "https://github.com/AriaMinaei/theatre",
|
||||
"directory": "packages/dataverse"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"main": "dist/index.cjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.mjs",
|
||||
"default": "./dist/index.cjs",
|
||||
"node": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"scripts": {
|
||||
"prepack": "yarn run build",
|
||||
"typecheck": "yarn run build",
|
||||
"build": "tsc --build ./tsconfig.json"
|
||||
"build": "run-s build:ts build:js",
|
||||
"build:ts": "tsc --build ./tsconfig.json",
|
||||
"build:js": "node -r esbuild-register ./devEnv/build.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/lodash-es": "^4.17.4",
|
||||
"@types/node": "^15.6.2",
|
||||
"esbuild": "^0.12.5",
|
||||
"esbuild-register": "^2.5.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"typescript": "^4.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"lib": ["ESNext", "DOM"],
|
||||
"rootDir": "src",
|
||||
"types": ["jest", "node"],
|
||||
"emitDeclarationOnly": false,
|
||||
"emitDeclarationOnly": true,
|
||||
"target": "es6",
|
||||
"composite": true
|
||||
},
|
||||
|
|
|
@ -42,4 +42,4 @@
|
|||
"dependencies": {
|
||||
"@theatre/dataverse": "workspace:*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,4 +45,4 @@
|
|||
"peerDependencies": {
|
||||
"@theatre/core": "*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3760,7 +3760,10 @@ __metadata:
|
|||
"@types/jest": ^26.0.23
|
||||
"@types/lodash-es": ^4.17.4
|
||||
"@types/node": ^15.6.2
|
||||
esbuild: ^0.12.5
|
||||
esbuild-register: ^2.5.0
|
||||
lodash-es: ^4.17.21
|
||||
npm-run-all: ^4.1.5
|
||||
typescript: ^4.3.2
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
|
Loading…
Reference in a new issue