Skip to content

Commit

Permalink
fix(vite-plugin): change default export to named export (#1465)
Browse files Browse the repository at this point in the history
* Revert "fix(vite-plugin): ship in dual package format for compatibility with Vite (#1450)"

* fix(vite-plugin): change default export to named export
  • Loading branch information
timofei-iatsenko authored Feb 24, 2023
1 parent 1288228 commit 15510c1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/vite-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm install --save-dev @lingui/vite-plugin

```ts
import { UserConfig } from 'vite';
import lingui from '@lingui/vite-plugin'
import { lingui } from '@lingui/vite-plugin'

const config: UserConfig = {
plugins: [lingui()]
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from "./src"
export { default, lingui } from "./src"
22 changes: 3 additions & 19 deletions packages/vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"name": "@lingui/vite-plugin",
"version": "3.17.1",
"description": "Vite plugin for Lingui message catalogs",
"main": "./build/cjs/index.js",
"module": "./build/esm/index.js",
"types": "./build/esm/index.d.ts",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"license": "MIT",
"keywords": [
"vite-plugin",
Expand All @@ -18,10 +17,7 @@
"translation"
],
"scripts": {
"clean": "rimraf ./build",
"build:esm": "tsc --module esnext --outDir ./build/esm",
"build:cjs": "tsc --module commonjs --outDir ./build/cjs",
"build": "yarn clean && yarn build:esm && yarn build:cjs"
"build": "rimraf ./build && tsc"
},
"repository": {
"type": "git",
Expand All @@ -30,18 +26,6 @@
"bugs": {
"url": "https://github.com/lingui/js-lingui/issues"
},
"exports": {
".": {
"require": {
"types": "./build/cjs/index.d.ts",
"default": "./build/cjs/index.js"
},
"import": {
"types": "./build/esm/index.d.ts",
"default": "./build/esm/index.js"
}
}
},
"engines": {
"node": ">=14.0.0"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type LinguiConfigOpts = {
skipValidation?: boolean
}

export default function lingui(linguiConfig: LinguiConfigOpts = {}): Plugin {
export function lingui(linguiConfig: LinguiConfigOpts = {}): Plugin {
const config = getConfig(linguiConfig)

return {
Expand Down Expand Up @@ -56,3 +56,5 @@ export default function lingui(linguiConfig: LinguiConfigOpts = {}): Plugin {
},
}
}

export default lingui
4 changes: 2 additions & 2 deletions packages/vite-plugin/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from "path"
import vitePlugin from "../src"
import { lingui } from "../src"

describe("vite-plugin", () => {
it("should return compiled catalog", async () => {
const p = vitePlugin({
const p = lingui({
configPath: path.resolve(__dirname, ".linguirc"),
})
const result = await (p.transform as any)(
Expand Down
1 change: 0 additions & 1 deletion packages/vite-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"sourceMap": true,
"noEmit": false,
"declaration": true,
"moduleResolution": "Node",
"outDir": "./build",
"esModuleInterop": true,
"resolveJsonModule": true
Expand Down
2 changes: 1 addition & 1 deletion website/docs/ref/vite-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Simply add `@lingui/vite-plugin` inside your `vite.config.ts`:

```ts title="vite.config.ts"
import { UserConfig } from 'vite';
import lingui from '@lingui/vite-plugin'
import { lingui } from '@lingui/vite-plugin'

const config: UserConfig = {
plugins: [lingui()]
Expand Down

1 comment on commit 15510c1

@vercel
Copy link

@vercel vercel bot commented on 15510c1 Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.