Skip to content

Commit

Permalink
fix: temporary fix cannot import vite in Yarn PnP
Browse files Browse the repository at this point in the history
Temporary fix #15
  • Loading branch information
nix6839 committed Mar 13, 2024
1 parent 5a40c78 commit ad67e5b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { visualizer } from 'rollup-plugin-visualizer'
import importFrom from 'import-from-esm'
import * as fs from 'node:fs'

/**
* @returns {Promise<import('vite')>}
*/
async function importVite() {
/** @type {import('vite')} */
let vite = await importFrom.silent(process.cwd(), 'vite');
try {
vite ??= await import(import.meta.resolve('vite'));
} catch {}
return vite;
}

const start = async ({
help,
template = 'treemap',
Expand All @@ -21,8 +33,7 @@ const start = async ({
}

// import from cwd's node_modules
/** @type {import('vite')} */
const { build } = await importFrom(process.cwd(), 'vite')
const { build } = await importVite()

let outFile

Expand Down

0 comments on commit ad67e5b

Please sign in to comment.