Skip to content

Commit

Permalink
cleanup esbuild configs
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav committed Feb 17, 2024
1 parent 1996839 commit 89fa6ac
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 8 deletions.
2 changes: 1 addition & 1 deletion esbuild.proxy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function createProxyServer(localServer, proxyPort = 3000) {
http.createServer(listenerFn).listen(proxyPort);
console.log(
'\x1b[1m\x1b[92m',
'> Proxy: \x1b[4mhttp://' +
'> Open this 🦙 \x1b[4mhttp://' +
localServer.host +
':' +
proxyPort +
Expand Down
2 changes: 1 addition & 1 deletion esbuild.server.mjs → examples/sdk-esm/esbuild.dev.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import esbuild from 'esbuild';
import { createProxyServer } from './esbuild.proxy.mjs';
import { createProxyServer } from '../../esbuild.proxy.mjs';

const plugins = [];

Expand Down
2 changes: 1 addition & 1 deletion examples/sdk-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"main": "out/index.js",
"scripts": {
"start": "node ../../esbuild.server.mjs"
"dev": "node ./esbuild.dev.mjs"
},
"keywords": [],
"devDependencies": {
Expand Down
23 changes: 23 additions & 0 deletions examples/xcm-transfer/esbuild.dev.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import esbuild from 'esbuild';
import { createProxyServer } from '../../esbuild.proxy.mjs';

const plugins = [];

const options = {
entryPoints: ['src/index.ts'],
bundle: true,
format: 'esm',
platform: 'browser',
target: 'esnext',
preserveSymlinks: true,
treeShaking: true,
sourcemap: true,
outdir: 'out/',
logLevel: 'info',
};

const ctx = await esbuild.context({ ...options, plugins });
await ctx.rebuild();
await ctx.watch();
const localServer = await ctx.serve({ servedir: './', host: '127.0.0.1' });
createProxyServer(localServer);
2 changes: 1 addition & 1 deletion examples/xcm-transfer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"main": "out/index.js",
"scripts": {
"start": "node ../../esbuild.server.mjs"
"dev": "node ./esbuild.dev.mjs"
},
"keywords": [],
"devDependencies": {
Expand Down
19 changes: 19 additions & 0 deletions packages/sdk/esbuild.dev.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import esbuild from 'esbuild';

import { esmConfig, getPackageJson } from '../../esbuild.config.mjs';

const packageJson = getPackageJson(import.meta.url);
const peerDependencies = packageJson.peerDependencies || {};

const plugins = [];

const options = {
...esmConfig,
bundle: true,
sourcemap: true,
external: Object.keys(peerDependencies),
};

const ctx = await esbuild.context({ ...options, plugins });
await ctx.rebuild();
await ctx.watch();
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"module": "./build/index.mjs",
"types": "./build/types/index.d.ts",
"scripts": {
"build": "node ./esbuild.config.mjs",
"build:watch": "npm run build -- --watch",
"build": "npm run clean && node ./esbuild.dist.mjs",
"build:watch": "node ./esbuild.dev.mjs",
"postbuild": "tsc --emitDeclarationOnly --outDir build/types/",
"clean": "rimraf build",
"link": "npm ln",
Expand Down
1 change: 1 addition & 0 deletions packages/xcm-cfg/esbuild.dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const plugins = [];
const options = {
...esmConfig,
bundle: true,
sourcemap: true,
external: Object.keys(peerDependencies),
};

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/xcm-cfg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"module": "./build/index.mjs",
"types": "./build/types/index.d.ts",
"scripts": {
"build": "node ./esbuild.config.mjs",
"build": "npm run clean && node ./esbuild.dist.mjs",
"build:watch": "node ./esbuild.dev.mjs",
"postbuild": "tsc --emitDeclarationOnly --outDir build/types",
"clean": "rimraf build",
Expand Down
1 change: 1 addition & 0 deletions packages/xcm-sdk/esbuild.dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const plugins = [];
const options = {
...esmConfig,
bundle: true,
sourcemap: true,
external: Object.keys(peerDependencies),
};

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/xcm-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"module": "./build/index.mjs",
"types": "./build/types/index.d.ts",
"scripts": {
"build": "node ./esbuild.config.mjs",
"build": "npm run clean && node ./esbuild.config.mjs",
"build:watch": "node ./esbuild.dev.mjs",
"postbuild": "tsc --emitDeclarationOnly --outDir build/types",
"clean": "rimraf build",
Expand Down

0 comments on commit 89fa6ac

Please sign in to comment.