(WIP) Switch the rest of the build setup to esbuild - 1

This commit is contained in:
Aria Minaei 2021-06-18 21:03:44 +02:00
parent b13f1131c5
commit 7c2e12c233
7 changed files with 20 additions and 26 deletions

View file

@ -1,13 +1,8 @@
import path from 'path' import path from 'path'
import { import {definedGlobals} from '../../../theatre/devEnv/buildUtils'
convertObjectToWebpackDefinePaths,
getEnvConfig,
} from '../../../theatre/devEnv/webpack/createWebpackConfig'
const playgroundDir = path.join(__dirname, '..') const playgroundDir = path.join(__dirname, '..')
const envConfig = getEnvConfig(true)
const port = 8080 const port = 8080
require('esbuild') require('esbuild')
@ -24,13 +19,7 @@ require('esbuild')
// watch: true, // watch: true,
bundle: true, bundle: true,
sourcemap: true, sourcemap: true,
define: { define: definedGlobals,
global: 'window',
...convertObjectToWebpackDefinePaths({
process: {env: envConfig},
$env: envConfig,
}),
},
}, },
) )
.then((server: unknown) => { .then((server: unknown) => {

View file

@ -1,4 +1,5 @@
import path from 'path' import path from 'path'
import {definedGlobals} from './buildUtils'
for (const which of ['core', 'studio']) { for (const which of ['core', 'studio']) {
const pathToPackage = path.join(__dirname, '../', which) const pathToPackage = path.join(__dirname, '../', which)
@ -9,12 +10,7 @@ for (const which of ['core', 'studio']) {
outfile: path.join(pathToPackage, 'dist/index.js'), outfile: path.join(pathToPackage, 'dist/index.js'),
bundle: true, bundle: true,
sourcemap: true, sourcemap: true,
define: { define: definedGlobals,
global: 'window',
'process.env.version': JSON.stringify(
require('../studio/package.json').version,
),
},
} }
require('esbuild').build(esbuildConfig) require('esbuild').build(esbuildConfig)
} }

View file

@ -0,0 +1,6 @@
export const definedGlobals = {
global: 'window',
'process.env.version': JSON.stringify(
require('../studio/package.json').version,
),
}

View file

@ -13,10 +13,6 @@ interface ProcessEnv {
version: string version: string
} }
declare var process: {
env: ProcessEnv
}
declare module '*.svg' { declare module '*.svg' {
var s: string var s: string
export default s export default s

View file

@ -33,7 +33,7 @@
"@types/jest": "^26.0.23", "@types/jest": "^26.0.23",
"@types/lodash": "^4.14.170", "@types/lodash": "^4.14.170",
"@types/lodash-es": "^4.17.4", "@types/lodash-es": "^4.17.4",
"@types/node": "^15.6.2", "@types/node": "^15.12.3",
"@types/react": "^17.0.9", "@types/react": "^17.0.9",
"@types/react-dom": "^17.0.6", "@types/react-dom": "^17.0.6",
"@types/react-icons": "^3.0.0", "@types/react-icons": "^3.0.0",

View file

@ -5,7 +5,7 @@
"lib": ["es2017", "dom", "ESNext"], "lib": ["es2017", "dom", "ESNext"],
"rootDir": ".", "rootDir": ".",
"composite": true, "composite": true,
"types": ["jest"], "types": ["jest", "node"],
"plugins": [ "plugins": [
{ {
"name": "typescript-styled-plugin", "name": "typescript-styled-plugin",

View file

@ -4032,6 +4032,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^15.12.3":
version: 15.12.3
resolution: "@types/node@npm:15.12.3"
checksum: 1e7a4f5675416f4dd61a7c16a8754272d0772bec070c1737e848598dad5c4a04fd3d249aab2b456c0f66fbbe8eb0e831ae5d2a4873385fee33ccd4935a53d300
languageName: node
linkType: hard
"@types/node@npm:^15.6.2": "@types/node@npm:^15.6.2":
version: 15.6.2 version: 15.6.2
resolution: "@types/node@npm:15.6.2" resolution: "@types/node@npm:15.6.2"
@ -17676,7 +17683,7 @@ resolve@1.17.0:
"@types/jest": ^26.0.23 "@types/jest": ^26.0.23
"@types/lodash": ^4.14.170 "@types/lodash": ^4.14.170
"@types/lodash-es": ^4.17.4 "@types/lodash-es": ^4.17.4
"@types/node": ^15.6.2 "@types/node": ^15.12.3
"@types/react": ^17.0.9 "@types/react": ^17.0.9
"@types/react-dom": ^17.0.6 "@types/react-dom": ^17.0.6
"@types/react-icons": ^3.0.0 "@types/react-icons": ^3.0.0