Skip to content

Commit

Permalink
Fix(Techor): Error [ERR_REQUIRE_ESM]: require() of ES Module
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Mar 28, 2023
1 parent 226caff commit bdb54ec
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 182 deletions.
165 changes: 1 addition & 164 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/techor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
"shx": "^0.3.4",
"to-extend": "^1.5.4",
"to-line": "^1.5.0",
"upath": "^2.0.1",
"execa": "^7.1.1"
"upath": "^2.0.1"
},
"devDependencies": {
"dedent": "^0.7.0",
Expand Down
28 changes: 14 additions & 14 deletions packages/techor/src/commands/pack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { program } from 'commander'
import fg from 'fast-glob'
import { execaCommand } from 'execa'
import { execSync } from 'child_process'
import { type BuildOptions, context, Metafile } from 'esbuild'
import pAll from 'p-all'
import log, { chalk } from '@techor/log'
Expand Down Expand Up @@ -295,19 +295,19 @@ program.command('pack [entryPaths...]')
platform: 'type',
format: 'dts'
},
run: () => new Promise<void>((resolve) => {
const runTsc = () => execaCommand(line`
npx tsc --emitDeclarationOnly --preserveWatchOutput --declaration
--outDir ${options.outdir}
${options.watch && '--watch'}
`, {
stdio: 'inherit',
stripFinalNewline: false
})
.catch((reason) => {
process.exit()
})
.finally(resolve)
run: () => new Promise<void>((resolve, reject) => {
const runTsc = () => {
try {
execSync(line`npx tsc --emitDeclarationOnly --preserveWatchOutput --declaration --outDir ${options.outdir} ${options.watch && '--watch'}`, {
stdio: 'inherit'
})
} catch (error) {
if (error) {
reject(error.toString())
}
}
resolve()
}
if (options.watch) {
setTimeout(runTsc, 100)
} else {
Expand Down
34 changes: 34 additions & 0 deletions packages/techor/tests/standard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/techor/tests/standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
Expand All @@ -11,5 +12,8 @@
},
"files": [
"dist"
]
],
"devDependencies": {
"typescript": "^4.9.5"
}
}
3 changes: 2 additions & 1 deletion packages/techor/tests/standard/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"outDir": "dist"
},
"include": [
"src/**/*.{ts,tsx}",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.d.ts"
],
"exclude": [
Expand Down

0 comments on commit bdb54ec

Please sign in to comment.