Skip to content

Commit

Permalink
fix: fixi Cannot find module 'prettier-eslint'(#216
Browse files Browse the repository at this point in the history
  • Loading branch information
hatedMe committed Jun 1, 2024
1 parent 41fe336 commit 66bedd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"build:dev": "yarn build:extension && yarn build:worker",
"build": "yarn build:extension --minify && yarn build:worker --minify",
"build:extension": "esbuild ./src/extension.js --bundle --sourcemap --platform=node --target=node16 --external:vscode --external:./worker.mjs --outfile=./dist/extension.js",
"build:worker": "esbuild ./src/worker.mjs --bundle --sourcemap --platform=node --format=esm --target=node16 --outfile=./dist/worker.mjs",
"build:worker": "esbuild ./src/worker.mjs --bundle --sourcemap --platform=node --format=esm --external:prettier-eslint --target=node16 --outfile=./dist/worker.mjs",
"package:dev": "yarn build:dev && vsce package",
"package": "yarn build && vsce package",
"contributors:add": "all-contributors add",
Expand Down
4 changes: 0 additions & 4 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function formatter(document) {

const formatted = formatText({
text,
prettierEslintPath: getModulePath(document.fileName, 'prettier-eslint'),
filePath: document.fileName,
extensionConfig: { prettierLast },
});
Expand Down Expand Up @@ -121,11 +120,8 @@ function waitForActiveSupportedDocument() {
* by 'prettier-eslint' to resolve its internal dependencies (eslint and prettier).
*/
async function warmUpWorker(document) {
const prettierEslintPath = getModulePath(document.fileName, 'prettier-eslint');

formatText({
text: '',
prettierEslintPath,
filePath: document.fileName,
});
}
Expand Down
20 changes: 8 additions & 12 deletions src/worker.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isAbsolute } from 'path';
import { runAsWorker } from 'synckit';
import { pathToFileURL } from 'url';
import format from 'prettier-eslint';

runAsWorker(
/**
Expand All @@ -14,16 +15,11 @@ runAsWorker(
* }}
*/
async ({
text, prettierEslintPath, filePath, extensionConfig,
}) => {
const format = /** @type {typeof import('prettier-eslint')} */ (
(await import(isAbsolute(prettierEslintPath) ? pathToFileURL(prettierEslintPath) : prettierEslintPath)).default
);
return format({
text,
filePath,
logLevel: 'info',
prettierLast: extensionConfig?.prettierLast,
});
},
text, filePath, extensionConfig,
}) => format({
text,
filePath,
logLevel: 'info',
prettierLast: extensionConfig?.prettierLast,
}),
);

0 comments on commit 66bedd5

Please sign in to comment.