Skip to content

Commit

Permalink
[dev-tools] fix build for unirepo
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Aug 27, 2024
1 parent ca7d664 commit ab9e9c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion modules/dev-tools/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ set -e
DEV_TOOLS_DIR=$(dirname $0)/..
MODULES=`node $DEV_TOOLS_DIR/dist/helpers/get-config.js ".modules" | sed -E "s/,/ /g"`
IS_ESM=`node $DEV_TOOLS_DIR/dist/helpers/get-config.js ".esm"`
TS_PROJECT=`node $DEV_TOOLS_DIR/dist/helpers/get-config.js ".typescript.project"`

build_src() {
OUT_DIR=$1
TARGET=$2
(set -x; npx tspc --declaration --declarationMap --sourceMap --target $TARGET --outDir $OUT_DIR --project ./tsconfig.json)
(set -x; npx tspc --declaration --declarationMap --sourceMap --target $TARGET --outDir $OUT_DIR --project $TS_PROJECT)
}

build_module_esm() {
Expand Down
7 changes: 5 additions & 2 deletions modules/dev-tools/src/configuration/get-esbuild-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// / For bundles published to npm
import fs from 'fs';
import {join} from 'path';
import {join, dirname} from 'path';
import util from 'util';
import {getOcularConfig} from '../helpers/get-ocular-config.js';
import ext from 'esbuild-plugin-external-global';
Expand Down Expand Up @@ -104,11 +104,14 @@ export async function getBundleConfig(opts: BundleOptions): Promise<BuildOptions
// This script must be executed in a submodule's directory
const packageRoot = process.cwd();
const packageInfo = JSON.parse(fs.readFileSync(join(packageRoot, 'package.json'), 'utf-8'));
const projectRoot = dirname(packageRoot).endsWith('modules')
? join(packageRoot, '../..')
: packageRoot;

const devMode = opts.env === 'dev';

const ocularConfig = await getOcularConfig({
root: join(packageRoot, '../..'),
root: projectRoot,
aliasMode: devMode ? 'src' : 'dist'
});

Expand Down
6 changes: 5 additions & 1 deletion modules/dev-tools/src/helpers/get-ocular-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export type OcularConfig = {
globals?: {[pattern: string]: string};
};

typescript?: {
project: string;
};

lint?: {
paths?: string[];
extensions?: string[];
Expand Down Expand Up @@ -126,7 +130,7 @@ export async function getOcularConfig(
},

typescript: {
project: ''
project: 'tsconfig.json'
},

lint: {
Expand Down

0 comments on commit ab9e9c0

Please sign in to comment.