diff --git a/src/Utils.ts b/src/Utils.ts index b9111ed79f6..9a723750b18 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -705,4 +705,8 @@ export default class Utils { }); }); } + + public static parseJsonWithBom(s: string): any { + return JSON.parse(s.replace(/^\uFEFF/, '')); + } } diff --git a/src/m365/spfx/commands/project/base-project-command.ts b/src/m365/spfx/commands/project/base-project-command.ts index 6b66645af07..8910e4e91f4 100644 --- a/src/m365/spfx/commands/project/base-project-command.ts +++ b/src/m365/spfx/commands/project/base-project-command.ts @@ -1,6 +1,7 @@ import Command from "../../../../Command"; import { TsFile, Manifest, Project, ScssFile } from "./model"; import { Utils } from './project-upgrade/'; +import GlobalUtils from '../../../../Utils'; import * as path from 'path'; import * as fs from 'fs'; @@ -137,7 +138,7 @@ export abstract class BaseProjectCommand extends Command { const manifestFiles = srcFiles.filter(f => f.endsWith('.manifest.json')); const manifests: Manifest[] = manifestFiles.map((f) => { const manifestStr = Utils.removeSingleLineComments(fs.readFileSync(f, 'utf-8')); - const manifest: Manifest = JSON.parse(manifestStr); + const manifest: Manifest = GlobalUtils.parseJsonWithBom(manifestStr); manifest.path = f; return manifest; });