Skip to content

Commit

Permalink
fix: export
Browse files Browse the repository at this point in the history
  • Loading branch information
soc221b committed Jan 25, 2025
1 parent fd50c86 commit 96189da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 41 deletions.
3 changes: 1 addition & 2 deletions packages/unplugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
"types": "dist/unplugin/src/index.d.ts",
"scripts": {
"build": "rimraf dist bin && pnpm build-types && pnpm build-bundle",
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node14 --external:unplugin --external:webpack --outfile=dist/index.js && pnpm run patch-dist",
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node14 --external:unplugin --external:webpack --outfile=dist/index.js",
"build-types": "tsc -p . --emitDeclarationOnly --outDir dist",
"pack": "rm -f *.tgz && pnpm pack && node ../../scripts/rename-tgz.js",
"patch-dist": "ts-node ./scripts/patchEsbuildDist.ts",
"postinstall": "node -e \"try{require('./scripts/postinstall')}catch(e){}\"",
"release": "standard-version --skip.tag -t unplugin --preset=conventionalcommits --releaseCommitMessageFormat 'chore(release): @import-meta-env/unplugin@{{currentTag}}' --path .",
"test": "jest"
Expand Down
35 changes: 0 additions & 35 deletions packages/unplugin/scripts/patchEsbuildDist.ts

This file was deleted.

22 changes: 18 additions & 4 deletions packages/unplugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUnplugin } from "unplugin";
import { createUnplugin, UnpluginFactory } from "unplugin";
import colors from "picocolors";
import { version } from "../package.json";
import { resolveEnv, getPackageManagerExecCommand } from "../../shared";
Expand All @@ -10,8 +10,11 @@ import { transformProd } from "./transform-prod";
import { ViteResolvedConfig } from "./vite/types";
import { resolveEnvExampleKeys } from "packages/shared/resolve-env-example-keys";
import { SourceMap } from "magic-string";
import { JsPlugin } from "@farmfe/core";

const createPlugin = createUnplugin<PluginOptions>((options, meta) => {
export type Options = PluginOptions;

export const unpluginFactory: UnpluginFactory<Options> = (options, meta) => {
const debug = process.env.DEBUG_IMPORT_META_ENV;
debug && console.debug("factory::", options, meta);

Expand Down Expand Up @@ -229,6 +232,17 @@ const createPlugin = createUnplugin<PluginOptions>((options, meta) => {
}
},
};
});
};

export const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);

export default unplugin;

export default createPlugin;
export const esbuild = unplugin.esbuild;
export const farm = unplugin.farm satisfies (
options: PluginOptions,
) => JsPlugin;
export const rollup = unplugin.rollup;
export const vite = unplugin.vite;
export const webpack = unplugin.webpack;
export const rspack = unplugin.rspack;

0 comments on commit 96189da

Please sign in to comment.