Skip to content

Commit

Permalink
fix: use json-stringify-safe (#3174)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylqm authored Jul 3, 2023
1 parent b65a3c9 commit 50af541
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"expo": "^48.0.19",
"expo-device": "^5.0.0",
"fast-json-stable-stringify": "^2.1.0",
"json-complete": "^2.0.1",
"jsrsasign": "^10.7.1",
"memoizee": "^0.4.15",
"mime-types": "^2.1.35",
Expand All @@ -103,6 +102,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@types/chrome": "^0.0.161",
"@types/jest": "^29.2.3",
"@types/json-stringify-safe": "^5",
"@types/jsrsasign": "^10",
"@types/memoizee": "^0.4.8",
"@types/mime-types": "^2.1.1",
Expand Down Expand Up @@ -149,6 +149,7 @@
"jest-environment-jsdom": "^29.3.1",
"jest-expo": "^47.0.1",
"jest-html-reporter": "^3.7.0",
"json-stringify-safe": "^5.0.1",
"lint-staged": "^11.2.6",
"node-notifier": "^10.0.0",
"patch-package": "^7.0.0",
Expand Down
18 changes: 6 additions & 12 deletions packages/ext/development/devUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const lodash = require('lodash');
const childProcess = require('child_process');
const path = require('path');
// const util = require('util');
const jsonComplete = require('json-complete');
const stringify = require('json-stringify-safe');
const prettier = require('prettier');
const manifest = require('../src/manifest');

// TODO move to developmentConsts.js
Expand Down Expand Up @@ -63,17 +64,10 @@ function writePreviewWebpackConfigJson(webpackConfig, filename) {
// return `[ Function ${this.name}() ] ${this.toString()} `;
return `[ Function ${this.name}() ]`;
};
try {
fse.writeJsonSync(filename, webpackConfig, { spaces: 2 });
} catch (error) {
console.error(error);
console.log('>>>>>>>> Fallback to jsonComplete.encode <<<<<<<<<');
fse.writeJsonSync(filename, jsonComplete.encode(webpackConfig), {
spaces: 2,
});
} finally {
// noop
}
fse.writeFileSync(
filename,
prettier.format(stringify(webpackConfig), { parser: 'json' }),
);
// fs.writeFileSync(filename, util.inspect(webpackConfig), {
// encoding: 'utf-8',
// });
Expand Down
17 changes: 9 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5197,6 +5197,7 @@ __metadata:
"@starcoin/starcoin": 2.1.5
"@types/chrome": ^0.0.161
"@types/jest": ^29.2.3
"@types/json-stringify-safe": ^5
"@types/jsrsasign": ^10
"@types/memoizee": ^0.4.8
"@types/mime-types": ^2.1.1
Expand Down Expand Up @@ -5255,7 +5256,7 @@ __metadata:
jest-environment-jsdom: ^29.3.1
jest-expo: ^47.0.1
jest-html-reporter: ^3.7.0
json-complete: ^2.0.1
json-stringify-safe: ^5.0.1
jsrsasign: ^10.7.1
lint-staged: ^11.2.6
memoizee: ^0.4.15
Expand Down Expand Up @@ -8717,6 +8718,13 @@ __metadata:
languageName: node
linkType: hard

"@types/json-stringify-safe@npm:^5":
version: 5.0.0
resolution: "@types/json-stringify-safe@npm:5.0.0"
checksum: 2822c9341119f53ded3b98b9686199bf13f9ff25ebeeab409ceb02167c2d5872455bdad2a2fcc0d88bd71b35696bf63d3378c7b9ab0e3f09ebbf9775e46cefdd
languageName: node
linkType: hard

"@types/json5@npm:^0.0.29":
version: 0.0.29
resolution: "@types/json5@npm:0.0.29"
Expand Down Expand Up @@ -22105,13 +22113,6 @@ __metadata:
languageName: node
linkType: hard

"json-complete@npm:^2.0.1":
version: 2.0.1
resolution: "json-complete@npm:2.0.1"
checksum: b96269a916b85298416ea44fef3a93b5c8fccecfe51c5e3b2f2c1c280f7c897545127e801ae13ef00944968b8f461bf85fad8b591c8fdd6747d263193b34ecf6
languageName: node
linkType: hard

"json-parse-better-errors@npm:^1.0.1, json-parse-better-errors@npm:^1.0.2":
version: 1.0.2
resolution: "json-parse-better-errors@npm:1.0.2"
Expand Down

0 comments on commit 50af541

Please sign in to comment.