Skip to content

Commit 93434df

Browse files
fix: invalid package.json after 'npm run generatePackage' #3777
Problem: After enabling esModuleInterop in the tsconfig, 'npm run generatePackage' adds extra values to package.json. Solution: Instead of namespace imports (import * as assert from 'assert'), use default imports (import assert from 'assert') for the package.json file. Signed-off-by: nkomonen <[email protected]>
1 parent 2c26ac9 commit 93434df

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

scripts/build/generateConfigurationAttributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as fs from 'fs'
77
import { JSONSchema4 } from 'json-schema'
88
import { compile } from 'json-schema-to-typescript'
9-
import * as packageJson from '../../package.json'
9+
import packageJson from '../../package.json'
1010
import * as nlsJson from '../../package.nls.json'
1111

1212
const config = [

scripts/build/generateIcons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import webfont from 'webfont'
77
import * as path from 'path'
88
import * as fs from 'fs-extra'
9-
import * as packageJson from '../../package.json'
9+
import packageJson from '../../package.json'
1010

1111
const fontId = 'aws-toolkit-icons'
1212
const projectDir = process.cwd()
@@ -164,7 +164,7 @@ ${result.template}
164164

165165
const stylesheetPath = path.join(stylesheetsDir, 'icons.css')
166166
const cloud9Dest = path.join(iconsDir, 'cloud9', 'generated')
167-
const isValidIcon = (i: typeof icons[number]): i is Required<typeof i> => i.data !== undefined
167+
const isValidIcon = (i: (typeof icons)[number]): i is Required<typeof i> => i.data !== undefined
168168

169169
await fs.mkdirp(fontsDir)
170170
await fs.writeFile(dest, result.woff)

scripts/build/package.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// 3. restore the original package.json
1717
//
1818

19-
import type * as manifest from '../../package.json'
19+
import type PackageJson from '../../package.json'
2020
import * as child_process from 'child_process'
2121
import * as fs from 'fs-extra'
2222

@@ -116,7 +116,7 @@ function main() {
116116
fs.copyFileSync(packageJsonFile, `${packageJsonFile}.bk`)
117117
fs.copyFileSync(webpackConfigJsFile, `${webpackConfigJsFile}.bk`)
118118

119-
const packageJson: typeof manifest = JSON.parse(fs.readFileSync(packageJsonFile, { encoding: 'utf-8' }))
119+
const packageJson: typeof PackageJson = JSON.parse(fs.readFileSync(packageJsonFile, { encoding: 'utf-8' }))
120120
const versionSuffix = getVersionSuffix(args.feature)
121121
const version = packageJson.version
122122
// Setting the version to an arbitrarily high number stops VSC from auto-updating the beta extension

scripts/test/launchTestUtilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import * as child_process from 'child_process'
7-
import * as manifest from '../../package.json'
7+
import packageJson from '../../package.json'
88
import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath } from '@vscode/test-electron'
99
import { join, resolve } from 'path'
1010
import { runTests } from '@vscode/test-electron'
@@ -108,7 +108,7 @@ export async function getCliArgsToDisableExtensions(
108108
}
109109

110110
export function getMinVsCodeVersion(): string {
111-
const vsCodeVersion = manifest.engines.vscode
111+
const vsCodeVersion = packageJson.engines.vscode
112112

113113
// We assume that we specify a minium, so it matches ^<number>, so remove ^'s
114114
const sanitizedVersion = vsCodeVersion.replace('^', '')

0 commit comments

Comments
 (0)