diff --git a/packages/playground/devEnv/servePlayground.ts b/packages/playground/devEnv/servePlayground.ts index 5c7f790..06fcaa4 100644 --- a/packages/playground/devEnv/servePlayground.ts +++ b/packages/playground/devEnv/servePlayground.ts @@ -1,13 +1,8 @@ import path from 'path' -import { - convertObjectToWebpackDefinePaths, - getEnvConfig, -} from '../../../theatre/devEnv/webpack/createWebpackConfig' +import {definedGlobals} from '../../../theatre/devEnv/buildUtils' const playgroundDir = path.join(__dirname, '..') -const envConfig = getEnvConfig(true) - const port = 8080 require('esbuild') @@ -24,13 +19,7 @@ require('esbuild') // watch: true, bundle: true, sourcemap: true, - define: { - global: 'window', - ...convertObjectToWebpackDefinePaths({ - process: {env: envConfig}, - $env: envConfig, - }), - }, + define: definedGlobals, }, ) .then((server: unknown) => { diff --git a/theatre/devEnv/build.ts b/theatre/devEnv/build.ts index 2b8fd1f..da4fcea 100644 --- a/theatre/devEnv/build.ts +++ b/theatre/devEnv/build.ts @@ -1,4 +1,5 @@ import path from 'path' +import {definedGlobals} from './buildUtils' for (const which of ['core', 'studio']) { const pathToPackage = path.join(__dirname, '../', which) @@ -9,12 +10,7 @@ for (const which of ['core', 'studio']) { outfile: path.join(pathToPackage, 'dist/index.js'), bundle: true, sourcemap: true, - define: { - global: 'window', - 'process.env.version': JSON.stringify( - require('../studio/package.json').version, - ), - }, + define: definedGlobals, } require('esbuild').build(esbuildConfig) } diff --git a/theatre/devEnv/buildUtils.ts b/theatre/devEnv/buildUtils.ts new file mode 100644 index 0000000..48d1038 --- /dev/null +++ b/theatre/devEnv/buildUtils.ts @@ -0,0 +1,6 @@ +export const definedGlobals = { + global: 'window', + 'process.env.version': JSON.stringify( + require('../studio/package.json').version, + ), +} diff --git a/theatre/globals.d.ts b/theatre/globals.d.ts index b8c4666..b22bea7 100644 --- a/theatre/globals.d.ts +++ b/theatre/globals.d.ts @@ -13,10 +13,6 @@ interface ProcessEnv { version: string } -declare var process: { - env: ProcessEnv -} - declare module '*.svg' { var s: string export default s diff --git a/theatre/package.json b/theatre/package.json index e4bac28..8f06104 100644 --- a/theatre/package.json +++ b/theatre/package.json @@ -33,7 +33,7 @@ "@types/jest": "^26.0.23", "@types/lodash": "^4.14.170", "@types/lodash-es": "^4.17.4", - "@types/node": "^15.6.2", + "@types/node": "^15.12.3", "@types/react": "^17.0.9", "@types/react-dom": "^17.0.6", "@types/react-icons": "^3.0.0", diff --git a/theatre/tsconfig.json b/theatre/tsconfig.json index 4603166..b8906ab 100644 --- a/theatre/tsconfig.json +++ b/theatre/tsconfig.json @@ -5,7 +5,7 @@ "lib": ["es2017", "dom", "ESNext"], "rootDir": ".", "composite": true, - "types": ["jest"], + "types": ["jest", "node"], "plugins": [ { "name": "typescript-styled-plugin", diff --git a/yarn.lock b/yarn.lock index 37f09ca..27dd446 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4032,6 +4032,13 @@ __metadata: languageName: node 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": version: 15.6.2 resolution: "@types/node@npm:15.6.2" @@ -17676,7 +17683,7 @@ resolve@1.17.0: "@types/jest": ^26.0.23 "@types/lodash": ^4.14.170 "@types/lodash-es": ^4.17.4 - "@types/node": ^15.6.2 + "@types/node": ^15.12.3 "@types/react": ^17.0.9 "@types/react-dom": ^17.0.6 "@types/react-icons": ^3.0.0