@intlayer/babel 5.5.2
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 +72 -0
- package/dist/cjs/babel-plugin-intlayer.cjs +190 -0
- package/dist/cjs/babel-plugin-intlayer.cjs.map +1 -0
- package/dist/cjs/index.cjs +23 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/babel-plugin-intlayer.mjs +159 -0
- package/dist/esm/babel-plugin-intlayer.mjs.map +1 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/babel-plugin-intlayer.d.ts +11 -0
- package/dist/types/babel-plugin-intlayer.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +113 -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,72 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://intlayer.org">
|
|
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/intlayer">
|
|
9
|
+
<img alt="npm" src="https://img.shields.io/npm/v/intlayer.svg?labelColor=49516F&color=8994BC" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://npmjs.org/package/intlayer">
|
|
12
|
+
<img alt="downloads" src="https://badgen.net/npm/dm/intlayer?labelColor=49516F&color=8994BC" />
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://npmjs.org/package/intlayer">
|
|
15
|
+
<img alt="types included" src="https://badgen.net/npm/types/intlayer?labelColor=49516F&color=8994BC"
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
# @intlayer/babel: Babel plugin for Intlayer internationalization
|
|
20
|
+
|
|
21
|
+
**Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, Next.js, and Express.js.
|
|
22
|
+
|
|
23
|
+
The **`@intlayer/babel`** package is a Babel plugin that transforms Intlayer declaration files and provides internationalization features during the build process according to the [Intlayer configuration](https://intlayer.org/doc/concept/configuration).
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Add the plugin to your Babel configuration:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"plugins": ["@intlayer/babel"]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or with options:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"plugins": [
|
|
40
|
+
[
|
|
41
|
+
"@intlayer/babel",
|
|
42
|
+
{
|
|
43
|
+
"configPath": "./intlayer.config.js"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
Install the necessary package using your preferred package manager:
|
|
53
|
+
|
|
54
|
+
```bash packageManager="npm"
|
|
55
|
+
npm install @intlayer/babel
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```bash packageManager="pnpm"
|
|
59
|
+
pnpm add @intlayer/babel
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```bash packageManager="yarn"
|
|
63
|
+
yarn add @intlayer/babel
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Read about Intlayer
|
|
67
|
+
|
|
68
|
+
- [Intlayer Website](https://intlayer.org)
|
|
69
|
+
- [Intlayer Documentation](https://intlayer.org/docs)
|
|
70
|
+
- [Intlayer GitHub](https://github.com/aymericzip/intlayer)
|
|
71
|
+
|
|
72
|
+
- [Ask your questions to our smart documentation](https://intlayer.org/docs/chat)
|
|
@@ -0,0 +1,190 @@
|
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var babel_plugin_intlayer_exports = {};
|
|
30
|
+
__export(babel_plugin_intlayer_exports, {
|
|
31
|
+
babelPluginIntlayer: () => babelPluginIntlayer
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(babel_plugin_intlayer_exports);
|
|
34
|
+
var import_parser = require("@babel/parser");
|
|
35
|
+
var t = __toESM(require("@babel/types"));
|
|
36
|
+
var import_chokidar = require("@intlayer/chokidar");
|
|
37
|
+
var import_config = require("@intlayer/config");
|
|
38
|
+
var import_path = require("path");
|
|
39
|
+
const PACKAGE_LIST = [
|
|
40
|
+
"react-intlayer",
|
|
41
|
+
"react-intlayer/client",
|
|
42
|
+
"react-intlayer/server",
|
|
43
|
+
"next-intlayer",
|
|
44
|
+
"next-intlayer/server",
|
|
45
|
+
"next-intlayer/client",
|
|
46
|
+
"svelte-intlayer",
|
|
47
|
+
"vue-intlayer",
|
|
48
|
+
"angular-intlayer",
|
|
49
|
+
"preact-intlayer",
|
|
50
|
+
"solid-inltayer"
|
|
51
|
+
];
|
|
52
|
+
const CALLER_LIST = ["useIntlayer", "getIntlayer"];
|
|
53
|
+
const globalUsedKeys = /* @__PURE__ */ new Set();
|
|
54
|
+
let isThreeShakable = true;
|
|
55
|
+
const isFileInContentDir = (filePath, contentDirs) => {
|
|
56
|
+
return contentDirs.some((dir) => {
|
|
57
|
+
const normalizedDir = dir.replace(/[/\\]+$/, "");
|
|
58
|
+
return filePath.startsWith(normalizedDir);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const isValidIntlayerImport = (source) => {
|
|
62
|
+
return PACKAGE_LIST.includes(source);
|
|
63
|
+
};
|
|
64
|
+
const babelPluginIntlayer = () => {
|
|
65
|
+
const configuration = (0, import_config.getConfiguration)();
|
|
66
|
+
const dictionariesRoot = configuration.content.mainDir.replace(
|
|
67
|
+
/[/\\]+$/,
|
|
68
|
+
""
|
|
69
|
+
);
|
|
70
|
+
const contentDir = configuration.content.contentDir;
|
|
71
|
+
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
72
|
+
return {
|
|
73
|
+
name: "babel-plugin-intlayer-prune",
|
|
74
|
+
visitor: {
|
|
75
|
+
Program: {
|
|
76
|
+
enter(_programPath, state) {
|
|
77
|
+
state.importedPackages = /* @__PURE__ */ new Set();
|
|
78
|
+
state.hasValidIntlayerImport = false;
|
|
79
|
+
const filePath = state.file.opts.filename ?? "";
|
|
80
|
+
if (!isFileInContentDir(filePath, contentDir)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
/*
|
|
85
|
+
* After the whole file has been walked, decide if THIS file is the
|
|
86
|
+
* dictionary entry-point. If it is, swap its body for the generated
|
|
87
|
+
* code that imports only the used dictionaries.
|
|
88
|
+
*/
|
|
89
|
+
exit(programPath, state) {
|
|
90
|
+
const filePath = state.file.opts.filename ?? "";
|
|
91
|
+
if (!isFileInContentDir(filePath, contentDir)) return;
|
|
92
|
+
if (!isThreeShakable) return;
|
|
93
|
+
if (!filePath.startsWith(dictionariesRoot)) return;
|
|
94
|
+
const keys = Array.from(globalUsedKeys);
|
|
95
|
+
if (!keys.length) return;
|
|
96
|
+
const extension = (0, import_path.extname)(filePath);
|
|
97
|
+
const format = extension === ".cjs" ? "cjs" : "esm";
|
|
98
|
+
const dictionaries = (0, import_chokidar.getBuiltDictionariesPath)(configuration).filter(
|
|
99
|
+
(p) => keys.some((k) => p.endsWith(`${import_path.sep}${k}.json`))
|
|
100
|
+
);
|
|
101
|
+
const generatedSrc = (0, import_chokidar.generateDictionaryListContent)(
|
|
102
|
+
dictionaries,
|
|
103
|
+
format,
|
|
104
|
+
configuration
|
|
105
|
+
);
|
|
106
|
+
if (!generatedSrc) return;
|
|
107
|
+
const newAst = (0, import_parser.parse)(generatedSrc, {
|
|
108
|
+
sourceType: format === "cjs" ? "script" : "module",
|
|
109
|
+
plugins: ["importMeta"]
|
|
110
|
+
});
|
|
111
|
+
appLogger("Unused dictionaries pruned to reduce bundle size", {
|
|
112
|
+
level: "info"
|
|
113
|
+
});
|
|
114
|
+
programPath.node.body = [];
|
|
115
|
+
programPath.pushContainer("body", newAst.program.body);
|
|
116
|
+
state.file.metadata = {
|
|
117
|
+
...state.file.metadata,
|
|
118
|
+
intlayerPruned: true
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
ImportDeclaration(path, state) {
|
|
123
|
+
const filePath = state.file.opts.filename ?? "";
|
|
124
|
+
if (!isFileInContentDir(filePath, contentDir)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const source = path.node.source.value;
|
|
128
|
+
state.importedPackages?.add(source);
|
|
129
|
+
if (isValidIntlayerImport(source)) {
|
|
130
|
+
const hasIntlayerFunction = path.node.specifiers.some((specifier) => {
|
|
131
|
+
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
|
|
132
|
+
return CALLER_LIST.includes(specifier.imported.name);
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
});
|
|
136
|
+
if (hasIntlayerFunction) {
|
|
137
|
+
state.hasValidIntlayerImport = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
CallExpression(path, state) {
|
|
142
|
+
const filePath = state.file.opts.filename ?? "";
|
|
143
|
+
if (!isFileInContentDir(filePath, contentDir)) return;
|
|
144
|
+
if (!isThreeShakable) return;
|
|
145
|
+
const { node } = path;
|
|
146
|
+
const renderError = (message) => {
|
|
147
|
+
const filePath2 = state.file.opts.filename ?? "";
|
|
148
|
+
const codeFrame = path.buildCodeFrameError("").message;
|
|
149
|
+
console.info("");
|
|
150
|
+
appLogger(message, {
|
|
151
|
+
level: "error"
|
|
152
|
+
});
|
|
153
|
+
appLogger(`At ${(0, import_path.relative)(process.cwd(), filePath2)}`, {
|
|
154
|
+
level: "error"
|
|
155
|
+
});
|
|
156
|
+
appLogger(codeFrame.split("\n").slice(1).join("\n"), {
|
|
157
|
+
level: "error"
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
if (t.isIdentifier(node.callee) && CALLER_LIST.includes(node.callee.name)) {
|
|
161
|
+
if (!state.hasValidIntlayerImport) {
|
|
162
|
+
isThreeShakable = false;
|
|
163
|
+
renderError(
|
|
164
|
+
`For dictionary optimization to work, ${node.callee.name} must be imported from one of these packages: ${PACKAGE_LIST.join(", ")}`
|
|
165
|
+
);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!node.arguments.length) {
|
|
169
|
+
isThreeShakable = false;
|
|
170
|
+
renderError(`${node.callee.name} requires at least one argument`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!t.isStringLiteral(node.arguments[0])) {
|
|
174
|
+
isThreeShakable = false;
|
|
175
|
+
renderError(
|
|
176
|
+
`For dictionary optimization to work, ${node.callee.name} key must be a literal string, otherwise tree shaking cannot be performed properly`
|
|
177
|
+
);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
globalUsedKeys.add(node.arguments[0].value);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
babelPluginIntlayer
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=babel-plugin-intlayer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/babel-plugin-intlayer.ts"],"sourcesContent":["import type { PluginObj, PluginPass } from '@babel/core';\nimport { parse } from '@babel/parser';\nimport type { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport {\n generateDictionaryListContent,\n getBuiltDictionariesPath,\n} from '@intlayer/chokidar';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { extname, relative, sep } from 'path';\n\ntype PluginState = PluginPass & {\n opts: {\n enableTransform?: boolean;\n };\n // Add tracking for imports per file\n importedPackages?: Set<string>;\n hasValidIntlayerImport?: boolean;\n};\n\n// ────────────────────────────────────────────────────────────\n// shared state across ALL files (1 build = 1 Node process)\nconst PACKAGE_LIST = [\n 'react-intlayer',\n 'react-intlayer/client',\n 'react-intlayer/server',\n 'next-intlayer',\n 'next-intlayer/server',\n 'next-intlayer/client',\n 'svelte-intlayer',\n 'vue-intlayer',\n 'angular-intlayer',\n 'preact-intlayer',\n 'solid-inltayer',\n];\nconst CALLER_LIST = ['useIntlayer', 'getIntlayer'];\nconst globalUsedKeys = new Set<string>();\nlet isThreeShakable = true;\n// ────────────────────────────────────────────────────────────\n\n// Helper function to check if file is in contentDir\nconst isFileInContentDir = (\n filePath: string,\n contentDirs: string[]\n): boolean => {\n return contentDirs.some((dir) => {\n const normalizedDir = dir.replace(/[/\\\\]+$/, '');\n return filePath.startsWith(normalizedDir);\n });\n};\n\n// Helper function to check if import is from valid package\nconst isValidIntlayerImport = (source: string): boolean => {\n return PACKAGE_LIST.includes(source);\n};\n\nexport const babelPluginIntlayer = (): PluginObj<PluginState> => {\n const configuration = getConfiguration();\n const dictionariesRoot: string = configuration.content.mainDir.replace(\n /[/\\\\]+$/,\n ''\n );\n const contentDir: string[] = configuration.content.contentDir;\n const appLogger = getAppLogger(configuration);\n\n return {\n name: 'babel-plugin-intlayer-prune',\n\n visitor: {\n Program: {\n enter(_programPath, state: PluginState) {\n // Initialize per-file state\n state.importedPackages = new Set<string>();\n state.hasValidIntlayerImport = false;\n\n const filePath: string = state.file.opts.filename ?? '';\n\n // Skip files that are not in contentDir\n if (!isFileInContentDir(filePath, contentDir)) {\n return;\n }\n },\n\n /*\n * After the whole file has been walked, decide if THIS file is the\n * dictionary entry-point. If it is, swap its body for the generated\n * code that imports only the used dictionaries.\n */\n exit(programPath, state: PluginState) {\n const filePath: string = state.file.opts.filename ?? '';\n\n // Skip files that are not in contentDir\n if (!isFileInContentDir(filePath, contentDir)) return;\n\n // Skip files is bundle is not three-shakable\n if (!isThreeShakable) return;\n\n // Is this *the* entry-point we want to shrink?\n if (!filePath.startsWith(dictionariesRoot)) return;\n\n const keys = Array.from(globalUsedKeys);\n if (!keys.length) return; // nothing collected yet – leave the file untouched\n\n const extension = extname(filePath); // .js / .mjs / .cjs\n const format = extension === '.cjs' ? 'cjs' : 'esm';\n\n // Pick only the dictionaries whose basename matches a collected key\n const dictionaries = getBuiltDictionariesPath(configuration).filter(\n (p) => keys.some((k) => p.endsWith(`${sep}${k}.json`))\n );\n\n const generatedSrc = generateDictionaryListContent(\n dictionaries,\n format,\n configuration\n );\n if (!generatedSrc) return;\n\n // Replace the current AST with the new one\n const newAst = parse(generatedSrc, {\n sourceType: format === 'cjs' ? 'script' : 'module',\n plugins: ['importMeta'],\n });\n\n appLogger('Unused dictionaries pruned to reduce bundle size', {\n level: 'info',\n });\n\n // Clear and inject\n programPath.node.body = [];\n programPath.pushContainer('body', newAst.program.body);\n\n // Optional: mark the file as \"transformed\" for other tooling\n state.file.metadata = {\n ...state.file.metadata,\n intlayerPruned: true,\n };\n },\n },\n\n ImportDeclaration(\n path: NodePath<t.ImportDeclaration>,\n state: PluginState\n ) {\n const filePath: string = state.file.opts.filename ?? '';\n\n // Skip files that are not in contentDir\n if (!isFileInContentDir(filePath, contentDir)) {\n return;\n }\n\n const source = path.node.source.value;\n state.importedPackages?.add(source);\n\n // Check if this import is from a valid intlayer package\n if (isValidIntlayerImport(source)) {\n // Check if any of the imported specifiers include useIntlayer or getIntlayer\n const hasIntlayerFunction = path.node.specifiers.some((specifier) => {\n if (\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported)\n ) {\n return CALLER_LIST.includes(specifier.imported.name);\n }\n return false;\n });\n\n if (hasIntlayerFunction) {\n state.hasValidIntlayerImport = true;\n }\n }\n },\n\n CallExpression(path: NodePath<t.CallExpression>, state: PluginState) {\n const filePath: string = state.file.opts.filename ?? '';\n\n // Skip files that are not in contentDir\n if (!isFileInContentDir(filePath, contentDir)) return;\n if (!isThreeShakable) return;\n\n const { node } = path;\n\n const renderError = (message: string) => {\n const filePath: string = state.file.opts.filename ?? '';\n\n // Generate code frame to show the error context\n const codeFrame = path.buildCodeFrameError('').message;\n\n console.info(''); // For formating\n appLogger(message, {\n level: 'error',\n });\n appLogger(`At ${relative(process.cwd(), filePath)}`, {\n level: 'error',\n });\n appLogger(codeFrame.split('\\n').slice(1).join('\\n'), {\n level: 'error',\n });\n };\n\n if (\n t.isIdentifier(node.callee) &&\n CALLER_LIST.includes(node.callee.name)\n ) {\n // Check if the function is imported from a valid package\n if (!state.hasValidIntlayerImport) {\n isThreeShakable = false;\n\n renderError(\n `For dictionary optimization to work, ${node.callee.name} must be imported from one of these packages: ${PACKAGE_LIST.join(', ')}`\n );\n return;\n }\n\n // Check if arguments exist\n if (!node.arguments.length) {\n isThreeShakable = false;\n\n renderError(`${node.callee.name} requires at least one argument`);\n\n return;\n }\n\n // Check if the first argument is a string literal\n if (!t.isStringLiteral(node.arguments[0])) {\n isThreeShakable = false;\n\n renderError(\n `For dictionary optimization to work, ${node.callee.name} key must be a literal string, otherwise tree shaking cannot be performed properly`\n );\n return;\n }\n\n globalUsedKeys.add(node.arguments[0].value);\n }\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAsB;AAEtB,QAAmB;AACnB,sBAGO;AACP,oBAA+C;AAC/C,kBAAuC;AAavC,MAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,cAAc,CAAC,eAAe,aAAa;AACjD,MAAM,iBAAiB,oBAAI,IAAY;AACvC,IAAI,kBAAkB;AAItB,MAAM,q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,gBAAM,YAAY,KAAK,oBAAoB,EAAE,EAAE;AAE/C,kBAAQ,KAAK,EAAE;AACf,oBAAU,SAAS;AAAA,YACjB,OAAO;AAAA,UACT,CAAC;AACD,oBAAU,UAAM,sBAAS,QAAQ,IAAI,GAAGA,SAAQ,CAAC,IAAI;AAAA,YACnD,OAAO;AAAA,UACT,CAAC;AACD,oBAAU,UAAU,MAAM,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,IAAI,GAAG;AAAA,YACnD,OAAO;AAAA,UACT,CAAC;AAAA,QACH;AAEA,YACE,EAAE,aAAa,KAAK,MAAM,KAC1B,YAAY,SAAS,KAAK,OAAO,IAAI,GACrC;AAEA,cAAI,CAAC,MAAM,wBAAwB;AACjC,8BAAkB;AAElB;AAAA,cACE,wCAAwC,KAAK,OAAO,IAAI,iDAAiD,aAAa,KAAK,IAAI,CAAC;AAAA,YAClI;AACA;AAAA,UACF;AAGA,cAAI,CAAC,KAAK,UAAU,QAAQ;AAC1B,8BAAkB;AAElB,wBAAY,GAAG,KAAK,OAAO,IAAI,iCAAiC;AAEhE;AAAA,UACF;AAGA,cAAI,CAAC,EAAE,gBAAgB,KAAK,UAAU,CAAC,CAAC,GAAG;AACzC,8BAAkB;AAElB;AAAA,cACE,wCAAwC,KAAK,OAAO,IAAI;AAAA,YAC1D;AACA;AAAA,UACF;AAEA,yBAAe,IAAI,KAAK,UAAU,CAAC,EAAE,KAAK;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["filePath"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require('./babel-plugin-intlayer.cjs'), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require('./babel-plugin-intlayer.cjs')
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './babel-plugin-intlayer';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,oCAAd;","names":[]}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
2
|
+
import * as t from "@babel/types";
|
|
3
|
+
import {
|
|
4
|
+
generateDictionaryListContent,
|
|
5
|
+
getBuiltDictionariesPath
|
|
6
|
+
} from "@intlayer/chokidar";
|
|
7
|
+
import { getAppLogger, getConfiguration } from "@intlayer/config";
|
|
8
|
+
import { extname, relative, sep } from "path";
|
|
9
|
+
const PACKAGE_LIST = [
|
|
10
|
+
"react-intlayer",
|
|
11
|
+
"react-intlayer/client",
|
|
12
|
+
"react-intlayer/server",
|
|
13
|
+
"next-intlayer",
|
|
14
|
+
"next-intlayer/server",
|
|
15
|
+
"next-intlayer/client",
|
|
16
|
+
"svelte-intlayer",
|
|
17
|
+
"vue-intlayer",
|
|
18
|
+
"angular-intlayer",
|
|
19
|
+
"preact-intlayer",
|
|
20
|
+
"solid-inltayer"
|
|
21
|
+
];
|
|
22
|
+
const CALLER_LIST = ["useIntlayer", "getIntlayer"];
|
|
23
|
+
const globalUsedKeys = /* @__PURE__ */ new Set();
|
|
24
|
+
let isThreeShakable = true;
|
|
25
|
+
const isFileInContentDir = (filePath, contentDirs) => {
|
|
26
|
+
return contentDirs.some((dir) => {
|
|
27
|
+
const normalizedDir = dir.replace(/[/\\]+$/, "");
|
|
28
|
+
return filePath.startsWith(normalizedDir);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const isValidIntlayerImport = (source) => {
|
|
32
|
+
return PACKAGE_LIST.includes(source);
|
|
33
|
+
};
|
|
34
|
+
const babelPluginIntlayer = () => {
|
|
35
|
+
const configuration = getConfiguration();
|
|
36
|
+
const dictionariesRoot = configuration.content.mainDir.replace(
|
|
37
|
+
/[/\\]+$/,
|
|
38
|
+
""
|
|
39
|
+
);
|
|
40
|
+
const contentDir = configuration.content.contentDir;
|
|
41
|
+
const appLogger = getAppLogger(configuration);
|
|
42
|
+
return {
|
|
43
|
+
name: "babel-plugin-intlayer-prune",
|
|
44
|
+
visitor: {
|
|
45
|
+
Program: {
|
|
46
|
+
enter(_programPath, state) {
|
|
47
|
+
state.importedPackages = /* @__PURE__ */ new Set();
|
|
48
|
+
state.hasValidIntlayerImport = false;
|
|
49
|
+
const filePath = state.file.opts.filename ?? "";
|
|
50
|
+
if (!isFileInContentDir(filePath, contentDir)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
/*
|
|
55
|
+
* After the whole file has been walked, decide if THIS file is the
|
|
56
|
+
* dictionary entry-point. If it is, swap its body for the generated
|
|
57
|
+
* code that imports only the used dictionaries.
|
|
58
|
+
*/
|
|
59
|
+
exit(programPath, state) {
|
|
60
|
+
const filePath = state.file.opts.filename ?? "";
|
|
61
|
+
if (!isFileInContentDir(filePath, contentDir)) return;
|
|
62
|
+
if (!isThreeShakable) return;
|
|
63
|
+
if (!filePath.startsWith(dictionariesRoot)) return;
|
|
64
|
+
const keys = Array.from(globalUsedKeys);
|
|
65
|
+
if (!keys.length) return;
|
|
66
|
+
const extension = extname(filePath);
|
|
67
|
+
const format = extension === ".cjs" ? "cjs" : "esm";
|
|
68
|
+
const dictionaries = getBuiltDictionariesPath(configuration).filter(
|
|
69
|
+
(p) => keys.some((k) => p.endsWith(`${sep}${k}.json`))
|
|
70
|
+
);
|
|
71
|
+
const generatedSrc = generateDictionaryListContent(
|
|
72
|
+
dictionaries,
|
|
73
|
+
format,
|
|
74
|
+
configuration
|
|
75
|
+
);
|
|
76
|
+
if (!generatedSrc) return;
|
|
77
|
+
const newAst = parse(generatedSrc, {
|
|
78
|
+
sourceType: format === "cjs" ? "script" : "module",
|
|
79
|
+
plugins: ["importMeta"]
|
|
80
|
+
});
|
|
81
|
+
appLogger("Unused dictionaries pruned to reduce bundle size", {
|
|
82
|
+
level: "info"
|
|
83
|
+
});
|
|
84
|
+
programPath.node.body = [];
|
|
85
|
+
programPath.pushContainer("body", newAst.program.body);
|
|
86
|
+
state.file.metadata = {
|
|
87
|
+
...state.file.metadata,
|
|
88
|
+
intlayerPruned: true
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
ImportDeclaration(path, state) {
|
|
93
|
+
const filePath = state.file.opts.filename ?? "";
|
|
94
|
+
if (!isFileInContentDir(filePath, contentDir)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const source = path.node.source.value;
|
|
98
|
+
state.importedPackages?.add(source);
|
|
99
|
+
if (isValidIntlayerImport(source)) {
|
|
100
|
+
const hasIntlayerFunction = path.node.specifiers.some((specifier) => {
|
|
101
|
+
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
|
|
102
|
+
return CALLER_LIST.includes(specifier.imported.name);
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
});
|
|
106
|
+
if (hasIntlayerFunction) {
|
|
107
|
+
state.hasValidIntlayerImport = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
CallExpression(path, state) {
|
|
112
|
+
const filePath = state.file.opts.filename ?? "";
|
|
113
|
+
if (!isFileInContentDir(filePath, contentDir)) return;
|
|
114
|
+
if (!isThreeShakable) return;
|
|
115
|
+
const { node } = path;
|
|
116
|
+
const renderError = (message) => {
|
|
117
|
+
const filePath2 = state.file.opts.filename ?? "";
|
|
118
|
+
const codeFrame = path.buildCodeFrameError("").message;
|
|
119
|
+
console.info("");
|
|
120
|
+
appLogger(message, {
|
|
121
|
+
level: "error"
|
|
122
|
+
});
|
|
123
|
+
appLogger(`At ${relative(process.cwd(), filePath2)}`, {
|
|
124
|
+
level: "error"
|
|
125
|
+
});
|
|
126
|
+
appLogger(codeFrame.split("\n").slice(1).join("\n"), {
|
|
127
|
+
level: "error"
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
if (t.isIdentifier(node.callee) && CALLER_LIST.includes(node.callee.name)) {
|
|
131
|
+
if (!state.hasValidIntlayerImport) {
|
|
132
|
+
isThreeShakable = false;
|
|
133
|
+
renderError(
|
|
134
|
+
`For dictionary optimization to work, ${node.callee.name} must be imported from one of these packages: ${PACKAGE_LIST.join(", ")}`
|
|
135
|
+
);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (!node.arguments.length) {
|
|
139
|
+
isThreeShakable = false;
|
|
140
|
+
renderError(`${node.callee.name} requires at least one argument`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!t.isStringLiteral(node.arguments[0])) {
|
|
144
|
+
isThreeShakable = false;
|
|
145
|
+
renderError(
|
|
146
|
+
`For dictionary optimization to work, ${node.callee.name} key must be a literal string, otherwise tree shaking cannot be performed properly`
|
|
147
|
+
);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
globalUsedKeys.add(node.arguments[0].value);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export {
|
|
157
|
+
babelPluginIntlayer
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=babel-plugin-intlayer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/babel-plugin-intlayer.ts"],"sourcesContent":["import type { PluginObj, PluginPass } from '@babel/core';\nimport { parse } from '@babel/parser';\nimport type { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport {\n generateDictionaryListContent,\n getBuiltDictionariesPath,\n} from '@intlayer/chokidar';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { extname, relative, sep } from 'path';\n\ntype PluginState = PluginPass & {\n opts: {\n enableTransform?: boolean;\n };\n // Add tracking for imports per file\n importedPackages?: Set<string>;\n hasValidIntlayerImport?: boolean;\n};\n\n// ────────────────────────────────────────────────────────────\n// shared state across ALL files (1 build = 1 Node process)\nconst PACKAGE_LIST = [\n 'react-intlayer',\n 'react-intlayer/client',\n 'react-intlayer/server',\n 'next-intlayer',\n 'next-intlayer/server',\n 'next-intlayer/client',\n 'svelte-intlayer',\n 'vue-intlayer',\n 'angular-intlayer',\n 'preact-intlayer',\n 'solid-inltayer',\n];\nconst CALLER_LIST = ['useIntlayer', 'getIntlayer'];\nconst globalUsedKeys = new Set<string>();\nlet isThreeShakable = true;\n// ────────────────────────────────────────────────────────────\n\n// Helper function to check if file is in contentDir\nconst isFileInContentDir = (\n filePath: string,\n contentDirs: string[]\n): boolean => {\n return contentDirs.some((dir) => {\n const normalizedDir = dir.replace(/[/\\\\]+$/, '');\n return filePath.startsWith(normalizedDir);\n });\n};\n\n// Helper function to check if import is from valid package\nconst isValidIntlayerImport = (source: string): boolean => {\n return PACKAGE_LIST.includes(source);\n};\n\nexport const babelPluginIntlayer = (): PluginObj<PluginState> => {\n const configuration = getConfiguration();\n const dictionariesRoot: string = configuration.content.mainDir.replace(\n /[/\\\\]+$/,\n ''\n );\n const contentDir: string[] = configuration.content.contentDir;\n const appLogger = getAppLogger(configuration);\n\n return {\n name: 'babel-plugin-intlayer-prune',\n\n visitor: {\n Program: {\n enter(_programPath, state: PluginState) {\n // Initialize per-file state\n state.importedPackages = new Set<string>();\n state.hasValidIntlayerImport = false;\n\n const filePath: string = state.file.opts.filename ?? '';\n\n // Skip files that are not in contentDir\n if (!isFileInContentDir(filePath, contentDir)) {\n return;\n }\n },\n\n /*\n * After the whole file has been walked, decide if THIS file is the\n * dictionary entry-point. If it is, swap its body for the generated\n * code that imports only the used dictionaries.\n */\n exit(programPath, state: PluginState) {\n const filePath: string = state.file.opts.filename ?? '';\n\n // Skip files that are not in contentDir\n if (!isFileInContentDir(filePath, contentDir)) return;\n\n // Skip files is bundle is not three-shakable\n if (!isThreeShakable) return;\n\n // Is this *the* entry-point we want to shrink?\n if (!filePath.startsWith(dictionariesRoot)) return;\n\n const keys = Array.from(globalUsedKeys);\n if (!keys.length) return; // nothing collected yet – leave the file untouched\n\n const extension = extname(filePath); // .js / .mjs / .cjs\n const format = extension === '.cjs' ? 'cjs' : 'esm';\n\n // Pick only the dictionaries whose basename matches a collected key\n const dictionaries = getBuiltDictionariesPath(configuration).filter(\n (p) => keys.some((k) => p.endsWith(`${sep}${k}.json`))\n );\n\n const generatedSrc = generateDictionaryListContent(\n dictionaries,\n format,\n configuration\n );\n if (!generatedSrc) return;\n\n // Replace the current AST with the new one\n const newAst = parse(generatedSrc, {\n sourceType: format === 'cjs' ? 'script' : 'module',\n plugins: ['importMeta'],\n });\n\n appLogger('Unused dictionaries pruned to reduce bundle size', {\n level: 'info',\n });\n\n // Clear and inject\n programPath.node.body = [];\n programPath.pushContainer('body', newAst.program.body);\n\n // Optional: mark the file as \"transformed\" for other tooling\n state.file.metadata = {\n ...state.file.metadata,\n intlayerPruned: true,\n };\n },\n },\n\n ImportDeclaration(\n path: NodePath<t.ImportDeclaration>,\n state: PluginState\n ) {\n const filePath: string = state.file.opts.filename ?? '';\n\n // Skip files that are not in contentDir\n if (!isFileInContentDir(filePath, contentDir)) {\n return;\n }\n\n const source = path.node.source.value;\n state.importedPackages?.add(source);\n\n // Check if this import is from a valid intlayer package\n if (isValidIntlayerImport(source)) {\n // Check if any of the imported specifiers include useIntlayer or getIntlayer\n const hasIntlayerFunction = path.node.specifiers.some((specifier) => {\n if (\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported)\n ) {\n return CALLER_LIST.includes(specifier.imported.name);\n }\n return false;\n });\n\n if (hasIntlayerFunction) {\n state.hasValidIntlayerImport = true;\n }\n }\n },\n\n CallExpression(path: NodePath<t.CallExpression>, state: PluginState) {\n const filePath: string = state.file.opts.filename ?? '';\n\n // Skip files that are not in contentDir\n if (!isFileInContentDir(filePath, contentDir)) return;\n if (!isThreeShakable) return;\n\n const { node } = path;\n\n const renderError = (message: string) => {\n const filePath: string = state.file.opts.filename ?? '';\n\n // Generate code frame to show the error context\n const codeFrame = path.buildCodeFrameError('').message;\n\n console.info(''); // For formating\n appLogger(message, {\n level: 'error',\n });\n appLogger(`At ${relative(process.cwd(), filePath)}`, {\n level: 'error',\n });\n appLogger(codeFrame.split('\\n').slice(1).join('\\n'), {\n level: 'error',\n });\n };\n\n if (\n t.isIdentifier(node.callee) &&\n CALLER_LIST.includes(node.callee.name)\n ) {\n // Check if the function is imported from a valid package\n if (!state.hasValidIntlayerImport) {\n isThreeShakable = false;\n\n renderError(\n `For dictionary optimization to work, ${node.callee.name} must be imported from one of these packages: ${PACKAGE_LIST.join(', ')}`\n );\n return;\n }\n\n // Check if arguments exist\n if (!node.arguments.length) {\n isThreeShakable = false;\n\n renderError(`${node.callee.name} requires at least one argument`);\n\n return;\n }\n\n // Check if the first argument is a string literal\n if (!t.isStringLiteral(node.arguments[0])) {\n isThreeShakable = false;\n\n renderError(\n `For dictionary optimization to work, ${node.callee.name} key must be a literal string, otherwise tree shaking cannot be performed properly`\n );\n return;\n }\n\n globalUsedKeys.add(node.arguments[0].value);\n }\n },\n },\n };\n};\n"],"mappings":"AACA,SAAS,aAAa;AAEtB,YAAY,OAAO;AACnB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,wBAAwB;AAC/C,SAAS,SAAS,UAAU,WAAW;AAavC,MAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,cAAc,CAAC,eAAe,aAAa;AACjD,MAAM,iBAAiB,oBAAI,IAAY;AACvC,IAAI,kBAAkB;AAItB,MAAM,qBAAqB,CACzB,UACA,gBACY;AACZ,SAAO,YAAY,KAAK,CAAC,QAAQ;AAC/B,UAAM,gBAAgB,IAAI,QAAQ,WAAW,EAAE;AAC/C,WAAO,SAAS,WAAW,aAAa;AAAA,EAC1C,CAAC;AACH;AAGA,MAAM,wBAAwB,CAAC,WAA4B;AACzD,SAAO,aAAa,SAAS,MAAM;AACrC;AAEO,MAAM,sBAAsB,MAA8B;AAC/D,QAAM,gBAAgB,iBAAiB;AACvC,QAAM,mBAA2B,cAAc,QAAQ,QAAQ;AAAA,IAC7D;AAAA,IACA;AAAA,EACF;AACA,QAAM,aAAuB,cAAc,QAAQ;AACnD,QAAM,YAAY,aAAa,aAAa;AAE5C,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,SAAS;AAAA,MACP,SAAS;AAAA,QACP,MAAM,cAAc,OAAoB;AAEtC,gBAAM,mBAAmB,oBAAI,IAAY;AACzC,gBAAM,yBAAyB;AAE/B,gBAAM,WAAmB,MAAM,KAAK,KAAK,YAAY;AAGrD,cAAI,CAAC,mBAAmB,UAAU,UAAU,GAAG;AAC7C;AAAA,UACF;AAAA,QACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOA,KAAK,aAAa,OAAoB;AACpC,gBA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AwC,KAAK,OAAO,IAAI;AAAA,YAC1D;AACA;AAAA,UACF;AAEA,yBAAe,IAAI,KAAK,UAAU,CAAC,EAAE,KAAK;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["filePath"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './babel-plugin-intlayer';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PluginObj, PluginPass } from '@babel/core';
|
|
2
|
+
type PluginState = PluginPass & {
|
|
3
|
+
opts: {
|
|
4
|
+
enableTransform?: boolean;
|
|
5
|
+
};
|
|
6
|
+
importedPackages?: Set<string>;
|
|
7
|
+
hasValidIntlayerImport?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const babelPluginIntlayer: () => PluginObj<PluginState>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=babel-plugin-intlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babel-plugin-intlayer.d.ts","sourceRoot":"","sources":["../../src/babel-plugin-intlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzD,KAAK,WAAW,GAAG,UAAU,GAAG;IAC9B,IAAI,EAAE;QACJ,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;IAEF,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAsCF,eAAO,MAAM,mBAAmB,QAAO,SAAS,CAAC,WAAW,CAsL3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intlayer/babel",
|
|
3
|
+
"version": "5.5.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "A Babel plugin for Intlayer that transforms declaration files and provides internationalization features during the build process according to the Intlayer configuration.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"intlayer",
|
|
8
|
+
"babel",
|
|
9
|
+
"plugin",
|
|
10
|
+
"internationalization",
|
|
11
|
+
"transpile",
|
|
12
|
+
"typescript",
|
|
13
|
+
"javascript",
|
|
14
|
+
"json",
|
|
15
|
+
"file"
|
|
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
|
+
"sideEffects": false,
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/types/index.d.ts",
|
|
41
|
+
"require": "./dist/cjs/index.cjs",
|
|
42
|
+
"import": "./dist/esm/index.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"main": "dist/cjs/index.cjs",
|
|
47
|
+
"module": "dist/esm/index.mjs",
|
|
48
|
+
"types": "dist/types/index.d.ts",
|
|
49
|
+
"typesVersions": {
|
|
50
|
+
"*": {
|
|
51
|
+
"package.json": [
|
|
52
|
+
"./package.json"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"./dist",
|
|
58
|
+
"./package.json"
|
|
59
|
+
],
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@babel/core": "^7.27.1",
|
|
62
|
+
"@babel/generator": "^7.27.1",
|
|
63
|
+
"@babel/parser": "^7.27.2",
|
|
64
|
+
"@babel/traverse": "^7.27.1",
|
|
65
|
+
"@intlayer/config": "5.5.2",
|
|
66
|
+
"@intlayer/chokidar": "5.5.2"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@babel/types": "^7.27.1",
|
|
70
|
+
"@changesets/cli": "2.28.1",
|
|
71
|
+
"@types/babel__core": "^7.20.5",
|
|
72
|
+
"@types/babel__generator": "^7.20.5",
|
|
73
|
+
"@types/babel__parser": "^7.1.5",
|
|
74
|
+
"@types/babel__traverse": "^7.20.5",
|
|
75
|
+
"@types/crypto-js": "^4.2.2",
|
|
76
|
+
"@types/node": "^22.13.10",
|
|
77
|
+
"@typescript-eslint/parser": "^8.27.0",
|
|
78
|
+
"concurrently": "^9.1.2",
|
|
79
|
+
"eslint": "^9.22.0",
|
|
80
|
+
"prettier": "^3.5.3",
|
|
81
|
+
"rimraf": "^6.0.1",
|
|
82
|
+
"tsc-alias": "^1.8.11",
|
|
83
|
+
"tsup": "^8.4.0",
|
|
84
|
+
"typescript": "^5.8.2",
|
|
85
|
+
"@utils/eslint-config": "1.0.4",
|
|
86
|
+
"@utils/ts-config-types": "1.0.4",
|
|
87
|
+
"@utils/tsup-config": "1.0.4",
|
|
88
|
+
"@utils/ts-config": "1.0.4"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"@intlayer/chokidar": "5.5.2",
|
|
92
|
+
"@intlayer/config": "5.5.2"
|
|
93
|
+
},
|
|
94
|
+
"engines": {
|
|
95
|
+
"node": ">=14.18"
|
|
96
|
+
},
|
|
97
|
+
"bug": {
|
|
98
|
+
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
99
|
+
},
|
|
100
|
+
"scripts": {
|
|
101
|
+
"build": "pnpm build:package & pnpm build:types",
|
|
102
|
+
"build:package": "tsup",
|
|
103
|
+
"build:types": "tsc --project ./tsconfig.types.json && tsc-alias --project ./tsconfig.types.json",
|
|
104
|
+
"clean": "rimraf ./dist",
|
|
105
|
+
"dev": "concurrently --prefix none \"tsup --watch\" \"tsc --project ./tsconfig.types.json --watch\" \"tsc-alias --project ./tsconfig.types.json --watch\"",
|
|
106
|
+
"lint": "eslint . --cache",
|
|
107
|
+
"lint:fix": "eslint . --cache --fix",
|
|
108
|
+
"prettier": "prettier . --check",
|
|
109
|
+
"prettier:fix": "prettier --write src/**/*",
|
|
110
|
+
"reset": "pnpm clean & pnpm build",
|
|
111
|
+
"test": ""
|
|
112
|
+
}
|
|
113
|
+
}
|