Skip to content

Commit

Permalink
fix ESM build
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Sep 2, 2021
1 parent f80c2f1 commit d097ae3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-dogs-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gqty/cli': patch
---

fix ESM build
9 changes: 9 additions & 0 deletions bob-esbuild.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { sep } from 'path';

const isCLIPackage = process.cwd().endsWith(sep + 'cli');

export const config: import('bob-esbuild').BobConfig = {
tsc: {
dirs: ['packages/*', 'examples/mercurius'],
},
verbose: true,
esbuildPluginOptions: isCLIPackage
? {
target: 'node12',
}
: undefined,
};
14 changes: 9 additions & 5 deletions packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { program } from 'commander';
import { readFileSync } from 'fs';
import { resolve } from 'path';
import { inspectWriteGenerate, defaultConfig, __innerState } from './index';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { defaultConfig, inspectWriteGenerate, __innerState } from './index';

__innerState.isCLI = true;

program
.version(
JSON.parse(
readFileSync(resolve(__dirname, '../package.json'), {
encoding: 'utf-8',
})
readFileSync(
resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'),
{
encoding: 'utf-8',
}
)
).version
)
.description('CLI for gqty');
Expand Down
7 changes: 2 additions & 5 deletions packages/cli/src/prettier.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
format as prettierFormat,
Options as PrettierOptions,
resolveConfig,
} from 'prettier';
import prettier, { Options as PrettierOptions } from 'prettier';

const { format: prettierFormat, resolveConfig } = prettier;
const commonConfig = resolveConfig(process.cwd());

export function formatPrettier(
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"rootDir": ".",
"outDir": "dist",
"declaration": true,
"target": "es2019",
"module": "CommonJS",
"target": "es2020",
"module": "es2020",
"strict": true,
"esModuleInterop": true,
"allowJs": false,
"jsx": "react",
"skipLibCheck": true,
"noUnusedLocals": true,
"moduleResolution": "node",
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
Expand Down

0 comments on commit d097ae3

Please sign in to comment.