Skip to content

Commit

Permalink
feat(react): fix macro export conditions for NodeNext and Bundler res…
Browse files Browse the repository at this point in the history
…olutions (#1915)
  • Loading branch information
timofei-iatsenko authored Jun 17, 2024
1 parent 4821317 commit 46ac32f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 34 deletions.
6 changes: 2 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@
}
},
"./macro": {
"require": {
"types": "./macro/index.d.ts",
"default": "./macro/index.js"
}
"types": "./macro/index.d.ts",
"default": "./macro/index.js"
},
"./package.json": "./package.json"
},
Expand Down
40 changes: 22 additions & 18 deletions packages/macro/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,70 +25,74 @@ import {
/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const t = _t
declare const t: typeof _t

/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const msg = _msg
declare const msg: typeof _msg
/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const plural = _plural
declare const plural: typeof _plural
/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const defineMessage = _defineMessage
declare const defineMessage: typeof _defineMessage
/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const select = _select
declare const select: typeof _select
/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const selectOrdinal = _selectOrdinal
declare const selectOrdinal: typeof _selectOrdinal
/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const SelectOptions = _SelectOptions
declare const SelectOptions: _SelectOptions
/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const ChoiceOptions = _ChoiceOptions
declare const ChoiceOptions: _ChoiceOptions
/**
* @deprecated please import from `@lingui/core/macro` directly
*/
const MacroMessageDescriptor = _MacroMessageDescriptor
declare const MacroMessageDescriptor: _MacroMessageDescriptor

export const Trans = _Trans
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const Plural = _Plural
declare const Trans: typeof _Trans
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const Plural: typeof _Plural
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const PluralChoiceProps = _PluralChoiceProps
export const PluralChoiceProps: _PluralChoiceProps
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const SelectChoiceProps = _SelectChoiceProps
export const SelectChoiceProps: _SelectChoiceProps
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const Select = _Select
export const Select: typeof _Select
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const CommonProps = _CommonProps
export const CommonProps: _CommonProps
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const SelectOrdinal = _SelectOrdinal
export const SelectOrdinal: typeof _SelectOrdinal
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const TransProps = _TransProps
export const TransProps: _TransProps
/**
* @deprecated please import from `@lingui/react/macro` directly
*/
export const useLingui = _useLingui
export const useLingui: typeof _useLingui
8 changes: 3 additions & 5 deletions packages/macro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@lingui/macro",
"version": "4.8.0-next.1",
"description": "Macro for generating messages in ICU MessageFormat syntax",
"main": "./index.cjs",
"main": "./index.js",
"types": "./index.d.ts",
"sideEffects": false,
"author": {
Expand Down Expand Up @@ -35,10 +35,8 @@
},
"exports": {
".": {
"require": {
"types": "./index.d.ts",
"default": "./index.cjs"
}
"types": "./index.d.ts",
"default": "./index.js"
}
},
"files": [
Expand Down
7 changes: 5 additions & 2 deletions packages/react/macro/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ export const SelectOrdinal: VFC<PluralChoiceProps>
*/
export const Select: VFC<SelectChoiceProps>

function _t(descriptor: MacroMessageDescriptor): string
function _t(literals: TemplateStringsArray, ...placeholders: any[]): string
declare function _t(descriptor: MacroMessageDescriptor): string
declare function _t(
literals: TemplateStringsArray,
...placeholders: any[]
): string

/**
*
Expand Down
6 changes: 2 additions & 4 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@
}
},
"./macro": {
"require": {
"types": "./macro/index.d.ts",
"default": "./macro/index.js"
}
"types": "./macro/index.d.ts",
"default": "./macro/index.js"
},
"./package.json": "./package.json"
},
Expand Down
4 changes: 4 additions & 0 deletions test/typescript-nodenext-resolution/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

import { i18n } from "@lingui/core"
import { Trans } from "@lingui/react"
import { t as t1 } from "@lingui/macro"
import { t } from "@lingui/core/macro"
import { Trans as TransMacro } from "@lingui/react/macro"

console.log(i18n)
console.log(Trans)
console.log(t1, t, TransMacro)
1 change: 1 addition & 0 deletions test/typescript-nodenext-resolution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"dependencies": {
"@lingui/core": "workspace:*",
"@lingui/macro": "workspace:*",
"@lingui/react": "workspace:*"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3604,7 +3604,7 @@ __metadata:
languageName: unknown
linkType: soft

"@lingui/macro@workspace:packages/macro":
"@lingui/macro@workspace:*, @lingui/macro@workspace:packages/macro":
version: 0.0.0-use.local
resolution: "@lingui/macro@workspace:packages/macro"
dependencies:
Expand Down Expand Up @@ -15379,6 +15379,7 @@ __metadata:
resolution: "typescript-nodenext-resolution@workspace:test/typescript-nodenext-resolution"
dependencies:
"@lingui/core": "workspace:*"
"@lingui/macro": "workspace:*"
"@lingui/react": "workspace:*"
typescript: 4.9.5
languageName: unknown
Expand Down

0 comments on commit 46ac32f

Please sign in to comment.