From d3508af4c48bb134913ba6947e51252dcacf9c9f Mon Sep 17 00:00:00 2001 From: filip mertens Date: Fri, 3 Mar 2023 17:36:27 +0100 Subject: [PATCH] lazy load prettier --- apps/remix-ide/src/app/plugins/code-format.ts | 12 +++++++----- package.json | 3 ++- yarn.lock | 8 ++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/code-format.ts b/apps/remix-ide/src/app/plugins/code-format.ts index ac8d970936..674b98dbac 100644 --- a/apps/remix-ide/src/app/plugins/code-format.ts +++ b/apps/remix-ide/src/app/plugins/code-format.ts @@ -1,12 +1,7 @@ 'use strict' import { Plugin } from '@remixproject/engine' -import prettier from 'prettier/standalone' import { Options } from 'prettier'; import sol from './code-format/index' -import * as ts from 'prettier/parser-typescript' -import * as babel from 'prettier/parser-babel' -import * as espree from 'prettier/parser-espree' -import * as yml from 'prettier/parser-yaml' import path from 'path' import yaml from 'js-yaml' import toml from 'toml' @@ -73,6 +68,13 @@ export class CodeFormat extends Plugin { async format(file: string) { + // lazy load + const prettier = await import('prettier/standalone') + const ts = await import('prettier/parser-typescript') + const babel = await import('prettier/parser-babel') + const espree = await import('prettier/parser-espree') + const yml = await import('prettier/parser-yaml') + try { const content = await this.call('fileManager', 'readFile', file) if (!content) return diff --git a/package.json b/package.json index b6505fde6b..1f3ddff92a 100644 --- a/package.json +++ b/package.json @@ -176,7 +176,7 @@ "merge": "^2.1.1", "npm-install-version": "^6.0.2", "path-browserify": "^1.0.1", - "prettier": "^2.7.1", + "prettier": "^2.8.4", "prettier-plugin-solidity": "^1.0.0-beta.24", "raw-loader": "^4.0.2", "react": "^17.0.2", @@ -335,6 +335,7 @@ "nyc": "^13.3.0", "onchange": "^3.2.1", "os-browserify": "^0.3.0", + "process": "^0.11.10", "react-refresh": "^0.14.0", "react-test-renderer": "^17.0.2", diff --git a/yarn.lock b/yarn.lock index 5cd1986312..121dc5a01f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22237,10 +22237,10 @@ prettier-plugin-solidity@^1.0.0-beta.24: solidity-comments-extractor "^0.0.7" string-width "^4.2.3" -prettier@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" - integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +prettier@^2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.4.tgz#34dd2595629bfbb79d344ac4a91ff948694463c3" + integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw== pretty-format@^27.0.0: version "27.2.5"