Skip to content

Commit

Permalink
minor import bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
NazmusSayad committed Sep 26, 2024
1 parent c3f4098 commit 8cfb47d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npmize",
"version": "1.1.1",
"version": "1.1.2",
"description": "Let's create an npm package without worrying about anything.",
"bin": "./dist/index.js",
"scripts": {
Expand Down
5 changes: 2 additions & 3 deletions src/__lab__/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
console.clear()
const TEST_TARGET = '../npmize-test'
const TEST_TARGET = '../uni-run'
import { app } from '../app'
import '../main'

// app.start(['init', TEST_TARGET])
// app.start(['dev', TEST_TARGET])
app.start(['dev', TEST_TARGET, '--node'])
// app.start(['build', TEST_TARGET])
app.start(['-v'])
2 changes: 1 addition & 1 deletion src/program/dev.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs'
import path from 'path'
import tsc from '../scripts/tsc'
import { cleanDir } from '../utils/fs'
import { CompileOptions } from './types.t'
import makeOutput from '../scripts/makeOutputFile'
import { getNodeModulesTempDir } from '../utils'
import { cleanDir } from '../utils/fs'

export default function (
rootPath: string,
Expand Down
5 changes: 3 additions & 2 deletions src/scripts/makeOutputFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export default function (filePath: string, options: MakeOutputOptions) {
)

const contentWithNodeCode =
(true ? pushNodeCode(newFilePath, newFileContent) : newFileContent) +
newFileContent
options.pushNodeCode && options.moduleType === 'cjs'
? pushNodeCode(newFilePath, newFileContent) + newFileContent
: newFileContent

autoCreateDir(path.dirname(newFilePath))
fs.writeFileSync(newFilePath, contentWithNodeCode)
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default function (
) {
const runner = options.async ? crossSpawn : crossSpawn.sync
runner('npx', ['tsc', ...args], {
stdio: options.stdio || 'inherit',
// stdio: options.stdio || 'inherit',
stdio: 'ignore',
cwd,
})
}
8 changes: 6 additions & 2 deletions src/scripts/tsconfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs'
import * as path from 'path'
import ts from 'typescript'
import ts, { ModuleKind } from 'typescript'

export function findTSConfigPath(targetPath: string) {
return ts.findConfigFile(targetPath, ts.sys.fileExists, 'tsconfig.json')
Expand Down Expand Up @@ -110,8 +110,12 @@ export function resolveImportPath(
importPath,
baseUrl,
{ baseUrl, paths },
moduleResolutionHost
moduleResolutionHost,
undefined,
undefined,
ModuleKind.CommonJS
)

if (resolved.resolvedModule?.packageId) return
return resolved.resolvedModule?.resolvedFileName
}

0 comments on commit 8cfb47d

Please sign in to comment.