react-scripts-intlayer 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +275 -0
- package/dist/cjs/cli/react-scripts-intlayer.cjs +73 -0
- package/dist/cjs/cli/react-scripts-intlayer.cjs.map +1 -0
- package/dist/cjs/craco.config.cjs +32 -0
- package/dist/cjs/craco.config.cjs.map +1 -0
- package/dist/cjs/intlayerCracoPlugin.cjs +93 -0
- package/dist/cjs/intlayerCracoPlugin.cjs.map +1 -0
- package/dist/cjs/removeUndefinedValueObject.cjs +38 -0
- package/dist/cjs/removeUndefinedValueObject.cjs.map +1 -0
- package/dist/esm/chunk-ZD7AOCMD.mjs +9 -0
- package/dist/esm/chunk-ZD7AOCMD.mjs.map +1 -0
- package/dist/esm/cli/react-scripts-intlayer.mjs +50 -0
- package/dist/esm/cli/react-scripts-intlayer.mjs.map +1 -0
- package/dist/esm/craco.config.mjs +17 -0
- package/dist/esm/craco.config.mjs.map +1 -0
- package/dist/esm/intlayerCracoPlugin.mjs +74 -0
- package/dist/esm/intlayerCracoPlugin.mjs.map +1 -0
- package/dist/esm/removeUndefinedValueObject.mjs +15 -0
- package/dist/esm/removeUndefinedValueObject.mjs.map +1 -0
- package/dist/types/cli/react-scripts-intlayer.d.ts +9 -0
- package/dist/types/cli/react-scripts-intlayer.d.ts.map +1 -0
- package/dist/types/craco.config.d.ts +2 -0
- package/dist/types/craco.config.d.ts.map +1 -0
- package/dist/types/intlayerCracoPlugin.d.ts +24 -0
- package/dist/types/intlayerCracoPlugin.d.ts.map +1 -0
- package/dist/types/removeUndefinedValueObject.d.ts +2 -0
- package/dist/types/removeUndefinedValueObject.d.ts.map +1 -0
- package/package.json +135 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright
|
|
52
|
+
owner or by an individual or Legal Entity authorized to submit on
|
|
53
|
+
behalf of the copyright owner. For the purposes of this definition,
|
|
54
|
+
"submitted" means any form of electronic, verbal, or written
|
|
55
|
+
communication sent to the Licensor or its representatives, including
|
|
56
|
+
but not limited to communication on electronic mailing lists, source
|
|
57
|
+
code control systems, and issue tracking systems that are managed by,
|
|
58
|
+
or on behalf of, the Licensor for the purpose of discussing and improving
|
|
59
|
+
the Work, but excluding communication that is conspicuously marked or
|
|
60
|
+
otherwise designated in writing by the copyright owner as "Not a
|
|
61
|
+
Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2024 Aymeric PINEAU
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://www.npmjs.com/package/react-intlayer">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/572ae9c9acafb74307b81530c1931a8e98990aef/docs/assets/logo.png" width="500" alt="intlayer" />
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/react-intlayer">
|
|
9
|
+
<img alt="npm" src="https://img.shields.io/npm/v/react-intlayer.svg?labelColor=49516F&color=8994BC" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://npmjs.org/package/react-intlayer">
|
|
12
|
+
<img alt="downloads" src="https://badgen.net/npm/dm/react-intlayer?labelColor=49516F&color=8994BC" />
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://npmjs.org/package/react-intlayer">
|
|
15
|
+
<img alt="types included" src="https://badgen.net/npm/types/react-intlayer?labelColor=49516F&color=8994BC"
|
|
16
|
+
/>
|
|
17
|
+
</a>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
# Intlayer: Next-Level Content Management in JavaScript
|
|
21
|
+
|
|
22
|
+
**Intlayer** is an internationalization library designed specifically for JavaScript developers. It allow the declaration of your content everywhere in your code. It converts declaration of multilingual content into structured dictionaries to integrate easily in your code. Using TypeScript, **Intlayer** make your development stronger and more efficient.
|
|
23
|
+
|
|
24
|
+
## Example of usage
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
.
|
|
28
|
+
├── Component1
|
|
29
|
+
│ ├── index.content.ts
|
|
30
|
+
│ └── index.tsx
|
|
31
|
+
└── Component2
|
|
32
|
+
├── index.content.ts
|
|
33
|
+
└── index.tsx
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
// ./Component1/index.content.ts
|
|
38
|
+
|
|
39
|
+
import { type DeclarationContent, t } from "intlayer";
|
|
40
|
+
|
|
41
|
+
const component1Content = {
|
|
42
|
+
key: "component1",
|
|
43
|
+
content: {
|
|
44
|
+
myTranslatedContent: t({
|
|
45
|
+
en: "Hello World",
|
|
46
|
+
fr: "Bonjour le monde",
|
|
47
|
+
es: "Hola Mundo",
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
} satisfies DeclarationContent;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
// ./Component1/index.tsx
|
|
55
|
+
|
|
56
|
+
import { useIntlayer } from "react-intlayer";
|
|
57
|
+
|
|
58
|
+
export const Component1 = () => {
|
|
59
|
+
const { myTranslatedContent } = useIntlayer("component1");
|
|
60
|
+
|
|
61
|
+
return <span>{myTranslatedContent}</span>;
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Why Choose Intlayer?
|
|
66
|
+
|
|
67
|
+
- **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
|
|
68
|
+
- **Type-Safe Environment**: Leverage TypeScript to ensure all your content definitions are precise and error-free.
|
|
69
|
+
- **Integrated Content Files**: Keep your translations close to their respective components, enhancing maintainability and clarity.
|
|
70
|
+
- **Simplified Setup**: Get up and running quickly with minimal configuration, especially optimized for Next.js projects.
|
|
71
|
+
- **Server Component Support**: Perfectly suited for Next.js server components, ensuring smooth server-side rendering.
|
|
72
|
+
- **Enhanced Routing**: Full support for Next.js app routing, adapting seamlessly to complex application structures.
|
|
73
|
+
|
|
74
|
+
# Getting Started with Intlayer and React Create App
|
|
75
|
+
|
|
76
|
+
Setting up Intlayer in a Create React App application is straightforward:
|
|
77
|
+
|
|
78
|
+
## Step 1: Install Dependencies
|
|
79
|
+
|
|
80
|
+
Install the necessary packages using npm:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install intlayer react-intlayer
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
yarn add intlayer react-intlayer
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pnpm add intlayer react-intlayer
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Step 2: Configuration of your project
|
|
95
|
+
|
|
96
|
+
Create a config file to configure the languages of your application:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// intlayer.config.ts
|
|
100
|
+
|
|
101
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
102
|
+
|
|
103
|
+
const config: IntlayerConfig = {
|
|
104
|
+
internationalization: {
|
|
105
|
+
locales: [
|
|
106
|
+
Locales.ENGLISH,
|
|
107
|
+
Locales.FRENCH,
|
|
108
|
+
Locales.SPANISH,
|
|
109
|
+
// Your other locales
|
|
110
|
+
],
|
|
111
|
+
defaultLocale: Locales.ENGLISH,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default config;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
To see all available parameters, refer to the [configuration documentation here](https://github.com/aymericzip/intlayer/blob/main/docs/en/configuration.md).
|
|
119
|
+
|
|
120
|
+
## Step 3: Integrate Intlayer in Your CRA Configuration
|
|
121
|
+
|
|
122
|
+
Change your scripts to use react-intlayer
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
"scripts": {
|
|
126
|
+
"build": "react-intlayer build",
|
|
127
|
+
"start": "react-intlayer start",
|
|
128
|
+
"transpile": "intlayer build"
|
|
129
|
+
},
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Note: react-intlayer scripts are based on craco. You can also implement your own setup based on the intlayer craco plugin. [See example here](https://github.com/aymericzip/intlayer/blob/main/examples/react-app/craco.config.js).
|
|
133
|
+
|
|
134
|
+
## Step 4: Declare Your Content
|
|
135
|
+
|
|
136
|
+
Create and manage your content dictionaries:
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
// src/app.content.tsx
|
|
140
|
+
import { t, type DeclarationContent } from "intlayer";
|
|
141
|
+
import { type ReactNode } from "react";
|
|
142
|
+
|
|
143
|
+
const appContent = {
|
|
144
|
+
key: "app",
|
|
145
|
+
content: {
|
|
146
|
+
getStarted: t<ReactNode>({
|
|
147
|
+
en: (
|
|
148
|
+
<>
|
|
149
|
+
Edit <code>src/App.tsx</code> and save to reload
|
|
150
|
+
</>
|
|
151
|
+
),
|
|
152
|
+
fr: (
|
|
153
|
+
<>
|
|
154
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour recharger
|
|
155
|
+
</>
|
|
156
|
+
),
|
|
157
|
+
es: (
|
|
158
|
+
<>
|
|
159
|
+
Edita <code>src/App.tsx</code> y guarda para recargar
|
|
160
|
+
</>
|
|
161
|
+
),
|
|
162
|
+
}),
|
|
163
|
+
reactLink: {
|
|
164
|
+
href: "https://reactjs.org",
|
|
165
|
+
content: t({
|
|
166
|
+
en: "Learn React",
|
|
167
|
+
fr: "Apprendre React",
|
|
168
|
+
es: "Aprender React",
|
|
169
|
+
}),
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
} satisfies DeclarationContent;
|
|
173
|
+
|
|
174
|
+
export default appContent;
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
[See how to declare your Intlayer declaration files](https://github.com/aymericzip/intlayer/blob/main/docs/en/content_declaration/get_started.md)
|
|
178
|
+
|
|
179
|
+
## Step 5: Utilize Intlayer in Your Code
|
|
180
|
+
|
|
181
|
+
Access your content dictionaries throughout your application:
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import logo from "./logo.svg";
|
|
185
|
+
import "./App.css";
|
|
186
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
187
|
+
import { LocaleSwitcher } from "./components/LangSwitcherDropDown";
|
|
188
|
+
|
|
189
|
+
function AppContent() {
|
|
190
|
+
const content = useIntlayer("app");
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<header className="App-header">
|
|
194
|
+
<img src={logo} className="App-logo" alt="logo" />
|
|
195
|
+
|
|
196
|
+
{content.getStarted}
|
|
197
|
+
<a
|
|
198
|
+
className="App-link"
|
|
199
|
+
href={content.reactLink.href.value}
|
|
200
|
+
target="_blank"
|
|
201
|
+
rel="noopener noreferrer"
|
|
202
|
+
>
|
|
203
|
+
{content.reactLink.content}
|
|
204
|
+
</a>
|
|
205
|
+
</header>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function App() {
|
|
210
|
+
return (
|
|
211
|
+
<IntlayerProvider>
|
|
212
|
+
<div className="App">
|
|
213
|
+
{/* To use the useIntlayer hook properly, you should access your data in a children component */}
|
|
214
|
+
<AppContent />
|
|
215
|
+
</div>
|
|
216
|
+
<div className="absolute bottom-5 right-5 z-50">
|
|
217
|
+
<LocaleSwitcher />
|
|
218
|
+
</div>
|
|
219
|
+
</IntlayerProvider>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export default App;
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
> Note: If you want to use your content in a `string` attribute, such as `alt`, `title`, `href`, `aria-label`, etc., you must call the value of the function, like:
|
|
227
|
+
>
|
|
228
|
+
> ```tsx
|
|
229
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
230
|
+
> ```
|
|
231
|
+
|
|
232
|
+
## (Optional) Step 6: Change the language of your content
|
|
233
|
+
|
|
234
|
+
To change the language of your content, you can use the `setLocale` function provided by the `useLocale` hook. This function allows you to set the locale of the application and update the content accordingly.
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { Locales } from "intlayer";
|
|
238
|
+
import { useLocale } from "react-intlayer";
|
|
239
|
+
|
|
240
|
+
const MyComponent = () => {
|
|
241
|
+
const { setLocale } = useLocale();
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<button onClick={() => setLocale(Locales.English)}>
|
|
245
|
+
Change Language to English
|
|
246
|
+
</button>
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Configure TypeScript
|
|
252
|
+
|
|
253
|
+
Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.
|
|
254
|
+
|
|
255
|
+

|
|
256
|
+
|
|
257
|
+

|
|
258
|
+
|
|
259
|
+
Ensure your TypeScript configuration includes the autogenerated types.
|
|
260
|
+
|
|
261
|
+
```json5
|
|
262
|
+
// tsconfig.json
|
|
263
|
+
|
|
264
|
+
{
|
|
265
|
+
// your custom config
|
|
266
|
+
"include": [
|
|
267
|
+
"src",
|
|
268
|
+
"types", // <- Include the auto generated types
|
|
269
|
+
],
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
# Getting Started with Intlayer and Vite + React
|
|
274
|
+
|
|
275
|
+
For integration with Vite + React, refer to the [setup guide](https://github.com/aymericzip/intlayer/blob/main/docs/en/intlayer_with_vite_react.md)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
var import_config = require("@intlayer/config");
|
|
26
|
+
var import_cross_spawn = __toESM(require("cross-spawn"));
|
|
27
|
+
const args = process.argv.slice(2);
|
|
28
|
+
const scriptIndex = args.findIndex(
|
|
29
|
+
(x) => x === "build" || x === "start" || x === "test"
|
|
30
|
+
);
|
|
31
|
+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
32
|
+
switch (script) {
|
|
33
|
+
case "build":
|
|
34
|
+
case "start":
|
|
35
|
+
case "test": {
|
|
36
|
+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
|
37
|
+
const scriptPath = import_config.ESMxCJSRequire.resolve(
|
|
38
|
+
`@craco/craco/dist/scripts/${script}`
|
|
39
|
+
);
|
|
40
|
+
const scriptArgs = args.slice(scriptIndex + 1);
|
|
41
|
+
const processArgs = nodeArgs.concat(scriptPath).concat([
|
|
42
|
+
...scriptArgs,
|
|
43
|
+
"--config",
|
|
44
|
+
"./node_modules/react-scripts-intlayer/dist/cjs/craco.config.cjs"
|
|
45
|
+
]);
|
|
46
|
+
const child = import_cross_spawn.default.sync("node", processArgs, {
|
|
47
|
+
stdio: "inherit"
|
|
48
|
+
});
|
|
49
|
+
if (child.signal) {
|
|
50
|
+
if (child.signal === "SIGKILL") {
|
|
51
|
+
(0, import_config.appLogger)(`
|
|
52
|
+
The build failed because the process exited too early.
|
|
53
|
+
This probably means the system ran out of memory or someone called
|
|
54
|
+
\`kill -9\` on the process.
|
|
55
|
+
`);
|
|
56
|
+
} else if (child.signal === "SIGTERM") {
|
|
57
|
+
(0, import_config.appLogger)(`
|
|
58
|
+
The build failed because the process exited too early.
|
|
59
|
+
Someone might have called \`kill\` or \`killall\`, or the system could
|
|
60
|
+
be shutting down.
|
|
61
|
+
`);
|
|
62
|
+
}
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
process.exit(child.status ?? void 0);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
(0, import_config.appLogger)(`Unknown script "${script}".`);
|
|
70
|
+
(0, import_config.appLogger)("Perhaps you need to update craco?");
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=react-scripts-intlayer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/react-scripts-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport { ESMxCJSRequire, appLogger } from '@intlayer/config';\nimport spawn from 'cross-spawn';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (x) => x === 'build' || x === 'start' || x === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\nswitch (script) {\n case 'build':\n case 'start':\n case 'test': {\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = ESMxCJSRequire.resolve(\n `@craco/craco/dist/scripts/${script}`\n );\n\n const scriptArgs = args.slice(scriptIndex + 1);\n const processArgs = nodeArgs\n .concat(scriptPath)\n .concat([\n ...scriptArgs,\n '--config',\n './node_modules/react-scripts-intlayer/dist/cjs/craco.config.cjs',\n ]);\n\n const child = spawn.sync('node', processArgs, {\n stdio: 'inherit',\n });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n appLogger(`\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n \\`kill -9\\` on the process.\n `);\n } else if (child.signal === 'SIGTERM') {\n appLogger(`\n The build failed because the process exited too early.\n Someone might have called \\`kill\\` or \\`killall\\`, or the system could\n be shutting down.\n `);\n }\n\n process.exit(1);\n }\n\n process.exit(child.status ?? undefined);\n break;\n }\n default:\n appLogger(`Unknown script \"${script}\".`);\n appLogger('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AASA,oBAA0C;AAC1C,yBAAkB;AAElB,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,cAAc,KAAK;AAAA,EACvB,CAAC,MAAM,MAAM,WAAW,MAAM,WAAW,MAAM;AACjD;AACA,MAAM,SAAS,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,WAAW;AAE9D,QAAQ,QAAQ;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK,QAAQ;AACX,UAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,WAAW,IAAI,CAAC;AACjE,UAAM,aAAa,6BAAe;AAAA,MAChC,6BAA6B,MAAM;AAAA,IACrC;AAEA,UAAM,aAAa,KAAK,MAAM,cAAc,CAAC;AAC7C,UAAM,cAAc,SACjB,OAAO,UAAU,EACjB,OAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAEH,UAAM,QAAQ,mBAAAA,QAAM,KAAK,QAAQ,aAAa;AAAA,MAC5C,OAAO;AAAA,IACT,CAAC;AAED,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,qCAAU;AAAA;AAAA;AAAA;AAAA,aAIL;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,qCAAU;AAAA;AAAA;AAAA;AAAA,aAIL;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,iCAAU,mBAAmB,MAAM,IAAI;AACvC,iCAAU,mCAAmC;AAC7C;AACJ;","names":["spawn"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var intlayerPlugin = __toESM(require('./intlayerCracoPlugin.cjs'));
|
|
25
|
+
module.exports = {
|
|
26
|
+
plugins: [
|
|
27
|
+
{
|
|
28
|
+
plugin: intlayerPlugin
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=craco.config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/craco.config.ts"],"sourcesContent":["import type { CracoConfig, CracoPlugin } from '@craco/types';\nimport * as intlayerPlugin from './intlayerCracoPlugin';\n\n// Usage Example\nmodule.exports = {\n plugins: [\n {\n plugin: intlayerPlugin as CracoPlugin,\n },\n ],\n} satisfies CracoConfig;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,qBAAgC;AAGhC,OAAO,UAAU;AAAA,EACf,SAAS;AAAA,IACP;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var intlayerCracoPlugin_exports = {};
|
|
20
|
+
__export(intlayerCracoPlugin_exports, {
|
|
21
|
+
overrideCracoConfig: () => overrideCracoConfig,
|
|
22
|
+
overrideWebpackConfig: () => overrideWebpackConfig,
|
|
23
|
+
plugin: () => plugin
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(intlayerCracoPlugin_exports);
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
var import_config = require("@intlayer/config");
|
|
28
|
+
var import_webpack = require("@intlayer/webpack");
|
|
29
|
+
var import_webpack2 = require("webpack");
|
|
30
|
+
var import_removeUndefinedValueObject = require('./removeUndefinedValueObject.cjs');
|
|
31
|
+
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
32
|
+
const env = (0, import_config.formatEnvVariable)("react_app");
|
|
33
|
+
const overrideWebpackConfig = ({
|
|
34
|
+
webpackConfig
|
|
35
|
+
}) => {
|
|
36
|
+
webpackConfig.externals = {
|
|
37
|
+
...typeof webpackConfig.externals === "object" ? webpackConfig.externals : {},
|
|
38
|
+
esbuild: "esbuild",
|
|
39
|
+
module: "module",
|
|
40
|
+
fs: "fs",
|
|
41
|
+
vm: "vm"
|
|
42
|
+
};
|
|
43
|
+
(webpackConfig.module?.rules ?? []).push({
|
|
44
|
+
test: /\.node$/,
|
|
45
|
+
use: "node-loader"
|
|
46
|
+
});
|
|
47
|
+
return webpackConfig;
|
|
48
|
+
};
|
|
49
|
+
const overrideCracoConfig = ({
|
|
50
|
+
cracoConfig
|
|
51
|
+
}) => {
|
|
52
|
+
const { mainDir, baseDir } = intlayerConfig.content;
|
|
53
|
+
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
|
|
54
|
+
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
55
|
+
return {
|
|
56
|
+
...cracoConfig,
|
|
57
|
+
webpack: {
|
|
58
|
+
...cracoConfig.webpack,
|
|
59
|
+
plugins: {
|
|
60
|
+
...cracoConfig.webpack?.plugins,
|
|
61
|
+
add: [
|
|
62
|
+
new import_webpack2.EnvironmentPlugin((0, import_removeUndefinedValueObject.removeUndefinedValueObject)(env)),
|
|
63
|
+
new import_webpack.IntLayerPlugin()
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
configure: {
|
|
67
|
+
...cracoConfig.webpack?.configure ?? {},
|
|
68
|
+
resolve: {
|
|
69
|
+
...cracoConfig.webpack?.configure?.resolve ?? {},
|
|
70
|
+
fallback: {
|
|
71
|
+
...cracoConfig.webpack?.configure?.resolve?.fallback ?? {},
|
|
72
|
+
process: import_config.ESMxCJSRequire.resolve("process/browser")
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
alias: {
|
|
77
|
+
...cracoConfig.webpack?.alias,
|
|
78
|
+
"@intlayer/dictionaries-entry": (0, import_path.resolve)("./", relativeDictionariesPath)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const plugin = {
|
|
84
|
+
overrideCracoConfig,
|
|
85
|
+
overrideWebpackConfig
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
overrideCracoConfig,
|
|
90
|
+
overrideWebpackConfig,
|
|
91
|
+
plugin
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=intlayerCracoPlugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport {\n getConfiguration,\n formatEnvVariable,\n ESMxCJSRequire,\n} from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport {\n type Configuration as WebpackConfig,\n EnvironmentPlugin,\n} from 'webpack';\nimport { removeUndefinedValueObject } from './removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n configure: {\n ...(cracoConfig.webpack?.configure ?? {}),\n resolve: {\n ...(cracoConfig.webpack?.configure?.resolve ?? {}),\n fallback: {\n ...(cracoConfig.webpack?.configure?.resolve?.fallback ?? {}),\n process: ESMxCJSRequire.resolve('process/browser'),\n },\n },\n },\n\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAwC;AAOxC,oBAIO;AACP,qBAAwD;AACxD,IAAAA,kBAGO;AACP,wCAA2C;AAG3C,MAAM,qBAAiB,gCAAiB;AAGxC,MAAM,UAA8B,iCAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,sCAAkB,8DAA2B,GAAG,CAAC;AAAA,UACrD,IAAI,eAAAC,eAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,WAAW;AAAA,QACT,GAAI,YAAY,SAAS,aAAa,CAAC;AAAA,QACvC,SAAS;AAAA,UACP,GAAI,YAAY,SAAS,WAAW,WAAW,CAAC;AAAA,UAChD,UAAU;AAAA,YACR,GAAI,YAAY,SAAS,WAAW,SAAS,YAAY,CAAC;AAAA,YAC1D,SAAS,6BAAe,QAAQ,iBAAiB;AAAA,UACnD;AAAA,QACF;AAAA,MACF;AAAA,MAEA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,oCAAgC,qBAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":["import_webpack","IntLayerWebpackPlugin"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var removeUndefinedValueObject_exports = {};
|
|
20
|
+
__export(removeUndefinedValueObject_exports, {
|
|
21
|
+
removeUndefinedValueObject: () => removeUndefinedValueObject
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(removeUndefinedValueObject_exports);
|
|
24
|
+
const removeUndefinedValueObject = (obj) => {
|
|
25
|
+
const newObj = {};
|
|
26
|
+
for (const key in obj) {
|
|
27
|
+
if (obj[key] !== void 0) {
|
|
28
|
+
newObj[key] = obj[key];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
Object.freeze(newObj);
|
|
32
|
+
return newObj;
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
removeUndefinedValueObject
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=removeUndefinedValueObject.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
__commonJS
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=chunk-ZD7AOCMD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { ESMxCJSRequire, appLogger } from "@intlayer/config";
|
|
3
|
+
import spawn from "cross-spawn";
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
const scriptIndex = args.findIndex(
|
|
6
|
+
(x) => x === "build" || x === "start" || x === "test"
|
|
7
|
+
);
|
|
8
|
+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
9
|
+
switch (script) {
|
|
10
|
+
case "build":
|
|
11
|
+
case "start":
|
|
12
|
+
case "test": {
|
|
13
|
+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
|
14
|
+
const scriptPath = ESMxCJSRequire.resolve(
|
|
15
|
+
`@craco/craco/dist/scripts/${script}`
|
|
16
|
+
);
|
|
17
|
+
const scriptArgs = args.slice(scriptIndex + 1);
|
|
18
|
+
const processArgs = nodeArgs.concat(scriptPath).concat([
|
|
19
|
+
...scriptArgs,
|
|
20
|
+
"--config",
|
|
21
|
+
"./node_modules/react-scripts-intlayer/dist/cjs/craco.config.cjs"
|
|
22
|
+
]);
|
|
23
|
+
const child = spawn.sync("node", processArgs, {
|
|
24
|
+
stdio: "inherit"
|
|
25
|
+
});
|
|
26
|
+
if (child.signal) {
|
|
27
|
+
if (child.signal === "SIGKILL") {
|
|
28
|
+
appLogger(`
|
|
29
|
+
The build failed because the process exited too early.
|
|
30
|
+
This probably means the system ran out of memory or someone called
|
|
31
|
+
\`kill -9\` on the process.
|
|
32
|
+
`);
|
|
33
|
+
} else if (child.signal === "SIGTERM") {
|
|
34
|
+
appLogger(`
|
|
35
|
+
The build failed because the process exited too early.
|
|
36
|
+
Someone might have called \`kill\` or \`killall\`, or the system could
|
|
37
|
+
be shutting down.
|
|
38
|
+
`);
|
|
39
|
+
}
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
process.exit(child.status ?? void 0);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
default:
|
|
46
|
+
appLogger(`Unknown script "${script}".`);
|
|
47
|
+
appLogger("Perhaps you need to update craco?");
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=react-scripts-intlayer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/react-scripts-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport { ESMxCJSRequire, appLogger } from '@intlayer/config';\nimport spawn from 'cross-spawn';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (x) => x === 'build' || x === 'start' || x === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\nswitch (script) {\n case 'build':\n case 'start':\n case 'test': {\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = ESMxCJSRequire.resolve(\n `@craco/craco/dist/scripts/${script}`\n );\n\n const scriptArgs = args.slice(scriptIndex + 1);\n const processArgs = nodeArgs\n .concat(scriptPath)\n .concat([\n ...scriptArgs,\n '--config',\n './node_modules/react-scripts-intlayer/dist/cjs/craco.config.cjs',\n ]);\n\n const child = spawn.sync('node', processArgs, {\n stdio: 'inherit',\n });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n appLogger(`\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n \\`kill -9\\` on the process.\n `);\n } else if (child.signal === 'SIGTERM') {\n appLogger(`\n The build failed because the process exited too early.\n Someone might have called \\`kill\\` or \\`killall\\`, or the system could\n be shutting down.\n `);\n }\n\n process.exit(1);\n }\n\n process.exit(child.status ?? undefined);\n break;\n }\n default:\n appLogger(`Unknown script \"${script}\".`);\n appLogger('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";AASA,SAAS,gBAAgB,iBAAiB;AAC1C,OAAO,WAAW;AAElB,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,cAAc,KAAK;AAAA,EACvB,CAAC,MAAM,MAAM,WAAW,MAAM,WAAW,MAAM;AACjD;AACA,MAAM,SAAS,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,WAAW;AAE9D,QAAQ,QAAQ;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK,QAAQ;AACX,UAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,WAAW,IAAI,CAAC;AACjE,UAAM,aAAa,eAAe;AAAA,MAChC,6BAA6B,MAAM;AAAA,IACrC;AAEA,UAAM,aAAa,KAAK,MAAM,cAAc,CAAC;AAC7C,UAAM,cAAc,SACjB,OAAO,UAAU,EACjB,OAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAEH,UAAM,QAAQ,MAAM,KAAK,QAAQ,aAAa;AAAA,MAC5C,OAAO;AAAA,IACT,CAAC;AAED,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,kBAAU;AAAA;AAAA;AAAA;AAAA,aAIL;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,kBAAU;AAAA;AAAA;AAAA;AAAA,aAIL;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,cAAU,mBAAmB,MAAM,IAAI;AACvC,cAAU,mCAAmC;AAC7C;AACJ;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS
|
|
3
|
+
} from './chunk-ZD7AOCMD.mjs';
|
|
4
|
+
import * as intlayerPlugin from './intlayerCracoPlugin.mjs';
|
|
5
|
+
var require_craco_config = __commonJS({
|
|
6
|
+
"src/craco.config.ts"(exports, module) {
|
|
7
|
+
module.exports = {
|
|
8
|
+
plugins: [
|
|
9
|
+
{
|
|
10
|
+
plugin: intlayerPlugin
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export default require_craco_config();
|
|
17
|
+
//# sourceMappingURL=craco.config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/craco.config.ts"],"sourcesContent":["import type { CracoConfig, CracoPlugin } from '@craco/types';\nimport * as intlayerPlugin from './intlayerCracoPlugin';\n\n// Usage Example\nmodule.exports = {\n plugins: [\n {\n plugin: intlayerPlugin as CracoPlugin,\n },\n ],\n} satisfies CracoConfig;\n"],"mappings":";;;AACA,YAAY,oBAAoB;AADhC;AAAA;AAIA,WAAO,UAAU;AAAA,MACf,SAAS;AAAA,QACP;AAAA,UACE,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "./chunk-ZD7AOCMD.mjs";
|
|
2
|
+
import { resolve, relative, join } from "path";
|
|
3
|
+
import {
|
|
4
|
+
getConfiguration,
|
|
5
|
+
formatEnvVariable,
|
|
6
|
+
ESMxCJSRequire
|
|
7
|
+
} from "@intlayer/config";
|
|
8
|
+
import { IntLayerPlugin as IntLayerWebpackPlugin } from "@intlayer/webpack";
|
|
9
|
+
import {
|
|
10
|
+
EnvironmentPlugin
|
|
11
|
+
} from "webpack";
|
|
12
|
+
import { removeUndefinedValueObject } from './removeUndefinedValueObject.mjs';
|
|
13
|
+
const intlayerConfig = getConfiguration();
|
|
14
|
+
const env = formatEnvVariable("react_app");
|
|
15
|
+
const overrideWebpackConfig = ({
|
|
16
|
+
webpackConfig
|
|
17
|
+
}) => {
|
|
18
|
+
webpackConfig.externals = {
|
|
19
|
+
...typeof webpackConfig.externals === "object" ? webpackConfig.externals : {},
|
|
20
|
+
esbuild: "esbuild",
|
|
21
|
+
module: "module",
|
|
22
|
+
fs: "fs",
|
|
23
|
+
vm: "vm"
|
|
24
|
+
};
|
|
25
|
+
(webpackConfig.module?.rules ?? []).push({
|
|
26
|
+
test: /\.node$/,
|
|
27
|
+
use: "node-loader"
|
|
28
|
+
});
|
|
29
|
+
return webpackConfig;
|
|
30
|
+
};
|
|
31
|
+
const overrideCracoConfig = ({
|
|
32
|
+
cracoConfig
|
|
33
|
+
}) => {
|
|
34
|
+
const { mainDir, baseDir } = intlayerConfig.content;
|
|
35
|
+
const dictionariesPath = join(mainDir, "dictionaries.mjs");
|
|
36
|
+
const relativeDictionariesPath = relative(baseDir, dictionariesPath);
|
|
37
|
+
return {
|
|
38
|
+
...cracoConfig,
|
|
39
|
+
webpack: {
|
|
40
|
+
...cracoConfig.webpack,
|
|
41
|
+
plugins: {
|
|
42
|
+
...cracoConfig.webpack?.plugins,
|
|
43
|
+
add: [
|
|
44
|
+
new EnvironmentPlugin(removeUndefinedValueObject(env)),
|
|
45
|
+
new IntLayerWebpackPlugin()
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
configure: {
|
|
49
|
+
...cracoConfig.webpack?.configure ?? {},
|
|
50
|
+
resolve: {
|
|
51
|
+
...cracoConfig.webpack?.configure?.resolve ?? {},
|
|
52
|
+
fallback: {
|
|
53
|
+
...cracoConfig.webpack?.configure?.resolve?.fallback ?? {},
|
|
54
|
+
process: ESMxCJSRequire.resolve("process/browser")
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
alias: {
|
|
59
|
+
...cracoConfig.webpack?.alias,
|
|
60
|
+
"@intlayer/dictionaries-entry": resolve("./", relativeDictionariesPath)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const plugin = {
|
|
66
|
+
overrideCracoConfig,
|
|
67
|
+
overrideWebpackConfig
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
overrideCracoConfig,
|
|
71
|
+
overrideWebpackConfig,
|
|
72
|
+
plugin
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=intlayerCracoPlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport {\n getConfiguration,\n formatEnvVariable,\n ESMxCJSRequire,\n} from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport {\n type Configuration as WebpackConfig,\n EnvironmentPlugin,\n} from 'webpack';\nimport { removeUndefinedValueObject } from './removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n configure: {\n ...(cracoConfig.webpack?.configure ?? {}),\n resolve: {\n ...(cracoConfig.webpack?.configure?.resolve ?? {}),\n fallback: {\n ...(cracoConfig.webpack?.configure?.resolve?.fallback ?? {}),\n process: ESMxCJSRequire.resolve('process/browser'),\n },\n },\n },\n\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";AAGA,SAAS,SAAS,UAAU,YAAY;AAOxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB,6BAA6B;AACxD;AAAA,EAEE;AAAA,OACK;AACP,SAAS,kCAAkC;AAG3C,MAAM,iBAAiB,iBAAiB;AAGxC,MAAM,MAA8B,kBAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAEnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,kBAAkB,2BAA2B,GAAG,CAAC;AAAA,UACrD,IAAI,sBAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,WAAW;AAAA,QACT,GAAI,YAAY,SAAS,aAAa,CAAC;AAAA,QACvC,SAAS;AAAA,UACP,GAAI,YAAY,SAAS,WAAW,WAAW,CAAC;AAAA,UAChD,UAAU;AAAA,YACR,GAAI,YAAY,SAAS,WAAW,SAAS,YAAY,CAAC;AAAA,YAC1D,SAAS,eAAe,QAAQ,iBAAiB;AAAA,UACnD;AAAA,QACF;AAAA,MACF;AAAA,MAEA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,gCAAgC,QAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./chunk-ZD7AOCMD.mjs";
|
|
2
|
+
const removeUndefinedValueObject = (obj) => {
|
|
3
|
+
const newObj = {};
|
|
4
|
+
for (const key in obj) {
|
|
5
|
+
if (obj[key] !== void 0) {
|
|
6
|
+
newObj[key] = obj[key];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
Object.freeze(newObj);
|
|
10
|
+
return newObj;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
removeUndefinedValueObject
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=removeUndefinedValueObject.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* To make the setup easier, we are using craco to override the webpack configuration.
|
|
4
|
+
* This script is used to run the craco scripts with the custom configuration.
|
|
5
|
+
*
|
|
6
|
+
* The script is based on the original craco script from create-react-app.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=react-scripts-intlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-scripts-intlayer.d.ts","sourceRoot":"","sources":["../../../src/cli/react-scripts-intlayer.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"craco.config.d.ts","sourceRoot":"","sources":["../../src/craco.config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CracoConfig, CracoConfigOverride, CracoPlugin, WebpackConfigOverride } from '@craco/types';
|
|
2
|
+
import { type Configuration as WebpackConfig } from 'webpack';
|
|
3
|
+
export declare const overrideWebpackConfig: ({ webpackConfig, }: WebpackConfigOverride) => WebpackConfig;
|
|
4
|
+
export declare const overrideCracoConfig: ({ cracoConfig, }: CracoConfigOverride) => CracoConfig;
|
|
5
|
+
/**
|
|
6
|
+
* A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const cracoConfig: CracoConfig = {
|
|
12
|
+
* plugins: [
|
|
13
|
+
* {
|
|
14
|
+
* plugin: intlayerCracoPlugin(),
|
|
15
|
+
* },
|
|
16
|
+
* ],
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* export default cracoConfig;
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare const plugin: CracoPlugin;
|
|
24
|
+
//# sourceMappingURL=intlayerCracoPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerCracoPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,KAAK,aAAa,IAAI,aAAa,EAEpC,MAAM,SAAS,CAAC;AAUjB,eAAO,MAAM,qBAAqB,uBAE/B,qBAAqB,KAAG,aAoB1B,CAAC;AAGF,eAAO,MAAM,mBAAmB,qBAE7B,mBAAmB,KAAG,WAkCxB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,EAAE,WAGpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeUndefinedValueObject.d.ts","sourceRoot":"","sources":["../../src/removeUndefinedValueObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OACrE,CAAC,KACL,CAYF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-scripts-intlayer",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Script for create react app application with intlayer",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"intlayer",
|
|
8
|
+
"data",
|
|
9
|
+
"internationalization",
|
|
10
|
+
"multilingual",
|
|
11
|
+
"i18n",
|
|
12
|
+
"typescript",
|
|
13
|
+
"react",
|
|
14
|
+
"vite",
|
|
15
|
+
"json"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://intlayer.org",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/aymericzip/intlayer.git"
|
|
24
|
+
},
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"author": {
|
|
27
|
+
"name": "Aymeric PINEAU",
|
|
28
|
+
"url": "https://github.com/aymericzip"
|
|
29
|
+
},
|
|
30
|
+
"contributors": [
|
|
31
|
+
{
|
|
32
|
+
"name": "Aymeric Pineau",
|
|
33
|
+
"email": "ay.pineau@gmail.com",
|
|
34
|
+
"url": "https://github.com/aymericzip"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/types/index.d.ts",
|
|
40
|
+
"require": "./dist/cjs/index.cjs",
|
|
41
|
+
"import": "./dist/esm/index.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./server": {
|
|
44
|
+
"types": "./dist/types/server/index.d.ts",
|
|
45
|
+
"require": "./dist/cjs/server/index.cjs",
|
|
46
|
+
"import": "./dist/esm/server/index.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./editor": {
|
|
49
|
+
"types": "./dist/types/editor/index.d.ts",
|
|
50
|
+
"require": "./dist/cjs/editor/index.cjs",
|
|
51
|
+
"import": "./dist/esm/editor/index.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./package.json": "./package.json"
|
|
54
|
+
},
|
|
55
|
+
"main": "dist/cjs/index.cjs",
|
|
56
|
+
"module": "dist/esm/index.mjs",
|
|
57
|
+
"types": "dist/types/index.d.ts",
|
|
58
|
+
"typesVersions": {
|
|
59
|
+
"*": {
|
|
60
|
+
"package.json": [
|
|
61
|
+
"./package.json"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"bin": {
|
|
66
|
+
"react-scripts-intlayer": "./dist/cjs/cli/react-scripts-intlayer.cjs"
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"./dist",
|
|
70
|
+
"./package.json"
|
|
71
|
+
],
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@craco/craco": "^7.1.0",
|
|
74
|
+
"node-loader": "^2.1.0",
|
|
75
|
+
"webpack": "^5.97.1",
|
|
76
|
+
"@intlayer/chokidar": "4.0.0",
|
|
77
|
+
"@intlayer/api": "4.0.0",
|
|
78
|
+
"@intlayer/config": "4.0.0",
|
|
79
|
+
"@intlayer/webpack": "4.0.0",
|
|
80
|
+
"@intlayer/dictionaries-entry": "4.0.0",
|
|
81
|
+
"@intlayer/core": "4.0.0"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@craco/types": "^7.1.0",
|
|
85
|
+
"@types/cross-spawn": "^6.0.6",
|
|
86
|
+
"@types/node": "^22.10.6",
|
|
87
|
+
"@types/webpack": "^5.28.5",
|
|
88
|
+
"@typescript-eslint/parser": "^8.20.0",
|
|
89
|
+
"concurrently": "^9.1.2",
|
|
90
|
+
"eslint": "^9.18.0",
|
|
91
|
+
"prettier": "^3.4.2",
|
|
92
|
+
"react": "^18.3.1",
|
|
93
|
+
"react-dom": "^18.3.1",
|
|
94
|
+
"rimraf": "^6.0.1",
|
|
95
|
+
"tsc-alias": "^1.8.10",
|
|
96
|
+
"tsup": "^8.3.5",
|
|
97
|
+
"typescript": "^5.7.3",
|
|
98
|
+
"@intlayer/backend": "4.0.0",
|
|
99
|
+
"@utils/eslint-config": "1.0.4",
|
|
100
|
+
"@utils/ts-config": "1.0.4",
|
|
101
|
+
"@utils/ts-config-types": "1.0.4",
|
|
102
|
+
"@utils/tsup-config": "1.0.4"
|
|
103
|
+
},
|
|
104
|
+
"peerDependencies": {
|
|
105
|
+
"react": ">=16.0.0",
|
|
106
|
+
"react-dom": ">=16.0.0",
|
|
107
|
+
"vite": ">=4.0.0",
|
|
108
|
+
"webpack": ">=5.0.0",
|
|
109
|
+
"@intlayer/chokidar": "4.0.0",
|
|
110
|
+
"@intlayer/config": "4.0.0",
|
|
111
|
+
"@intlayer/core": "4.0.0",
|
|
112
|
+
"@intlayer/dictionaries-entry": "4.0.0",
|
|
113
|
+
"@intlayer/webpack": "4.0.0",
|
|
114
|
+
"intlayer": "4.0.0"
|
|
115
|
+
},
|
|
116
|
+
"engines": {
|
|
117
|
+
"node": ">=14.18"
|
|
118
|
+
},
|
|
119
|
+
"bug": {
|
|
120
|
+
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
121
|
+
},
|
|
122
|
+
"scripts": {
|
|
123
|
+
"build": "pnpm build:package & pnpm build:types",
|
|
124
|
+
"build:package": "tsup",
|
|
125
|
+
"build:types": "tsc --project ./tsconfig.types.json && tsc-alias --project ./tsconfig.types.json",
|
|
126
|
+
"clean": "rimraf ./dist",
|
|
127
|
+
"dev": "concurrently --prefix none \"tsup --watch\" \"tsc --project ./tsconfig.types.json --watch\" \"tsc-alias --project ./tsconfig.types.json --watch\"",
|
|
128
|
+
"lint": "eslint . --cache",
|
|
129
|
+
"lint:fix": "eslint . --cache --fix",
|
|
130
|
+
"prettier": "prettier . --check",
|
|
131
|
+
"prettier:fix": "prettier . --write",
|
|
132
|
+
"test": "",
|
|
133
|
+
"typecheck": "tsup --project ./tsconfig.json --noEmit"
|
|
134
|
+
}
|
|
135
|
+
}
|