From f2739b0deadb5e516137f2f6dede4db4f1d95e38 Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Tue, 21 Feb 2023 12:38:23 +0100 Subject: [PATCH] fix(vite-plugin): ship in dual package format for compatibility with Vite --- packages/vite-plugin/package.json | 22 +++++++++++++++++++--- packages/vite-plugin/tsconfig.json | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json index 949990ceb..43a36d249 100644 --- a/packages/vite-plugin/package.json +++ b/packages/vite-plugin/package.json @@ -2,8 +2,9 @@ "name": "@lingui/vite-plugin", "version": "3.17.1", "description": "Vite plugin for Lingui message catalogs", - "main": "./build/index.js", - "types": "./build/index.d.ts", + "main": "./build/cjs/index.js", + "module": "./build/esm/index.js", + "types": "./build/esm/index.d.ts", "license": "MIT", "keywords": [ "vite-plugin", @@ -17,7 +18,10 @@ "translation" ], "scripts": { - "build": "rimraf ./build && tsc" + "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" }, "repository": { "type": "git", @@ -26,6 +30,18 @@ "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" }, diff --git a/packages/vite-plugin/tsconfig.json b/packages/vite-plugin/tsconfig.json index 6a44210eb..8cf1647eb 100644 --- a/packages/vite-plugin/tsconfig.json +++ b/packages/vite-plugin/tsconfig.json @@ -5,6 +5,7 @@ "sourceMap": true, "noEmit": false, "declaration": true, + "moduleResolution": "Node", "outDir": "./build", "esModuleInterop": true, "resolveJsonModule": true