@ttoss/config 1.35.5 → 1.35.7
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/dist/esm/index.js +84 -38
- package/dist/index.js +84 -38
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __name = (target2, value) => __defProp(target2, "name", {
|
|
5
|
+
value,
|
|
6
|
+
configurable: true
|
|
7
|
+
});
|
|
4
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
5
9
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
|
|
6
10
|
exports: {}
|
|
@@ -29,25 +33,25 @@ var require_babel_config = __commonJS({
|
|
|
29
33
|
}]],
|
|
30
34
|
plugins: [
|
|
31
35
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
* Carlin is full ESM and jest doesn't support import.meta.url from
|
|
37
|
+
* @ttoss/cloudformation. This plugin is needed to transform import.meta.url
|
|
38
|
+
*
|
|
39
|
+
* More reference about pure ESM packages:
|
|
40
|
+
* https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
|
41
|
+
*/
|
|
38
42
|
"babel-plugin-transform-import-meta",
|
|
39
43
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
* This plugin is needed to create a unique ID for each message in the
|
|
45
|
+
* translation files.
|
|
46
|
+
*/
|
|
43
47
|
["formatjs", {
|
|
44
48
|
idInterpolationPattern: "[sha512:contenthash:base64:6]",
|
|
45
49
|
ast: true
|
|
46
50
|
}],
|
|
47
51
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
* Decorators are not supported in ES6, so we need to use this plugin to
|
|
53
|
+
* transpile decorators to ES5.
|
|
54
|
+
*/
|
|
51
55
|
["@babel/plugin-proposal-decorators", {
|
|
52
56
|
version: "legacy"
|
|
53
57
|
}]]
|
|
@@ -57,16 +61,16 @@ var require_babel_config = __commonJS({
|
|
|
57
61
|
|
|
58
62
|
// src/configCreator.ts
|
|
59
63
|
import deepmerge from "deepmerge";
|
|
60
|
-
var overwriteMerge = (_, sourceArray) => {
|
|
64
|
+
var overwriteMerge = /* @__PURE__ */__name((_, sourceArray) => {
|
|
61
65
|
return sourceArray;
|
|
62
|
-
};
|
|
63
|
-
var configCreator = (defaultConfig8 = {}) => {
|
|
66
|
+
}, "overwriteMerge");
|
|
67
|
+
var configCreator = /* @__PURE__ */__name((defaultConfig8 = {}) => {
|
|
64
68
|
return (config = {}, deepmergeConfig) => {
|
|
65
69
|
return deepmerge(defaultConfig8, config, {
|
|
66
70
|
arrayMerge: deepmergeConfig?.arrayMerge === "overwrite" ? overwriteMerge : void 0
|
|
67
71
|
});
|
|
68
72
|
};
|
|
69
|
-
};
|
|
73
|
+
}, "configCreator");
|
|
70
74
|
|
|
71
75
|
// src/babel.ts
|
|
72
76
|
var defaultConfig = require_babel_config();
|
|
@@ -85,25 +89,25 @@ var defaultConfig3 = {
|
|
|
85
89
|
coverageDirectory: "coverage",
|
|
86
90
|
coverageProvider: "babel",
|
|
87
91
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
* https://github.com/jestjs/jest/issues/13739#issuecomment-1517190965
|
|
93
|
+
*/
|
|
90
94
|
extensionsToTreatAsEsm: [".ts", ".tsx"],
|
|
91
95
|
fakeTimers: {
|
|
92
96
|
advanceTimers: true,
|
|
93
97
|
enableGlobally: true
|
|
94
98
|
},
|
|
95
99
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
* https://stackoverflow.com/a/64390115/8786986
|
|
101
|
+
*/
|
|
98
102
|
moduleDirectories: ["node_modules", "<rootDir>/../.."],
|
|
99
103
|
moduleNameMapper: {
|
|
100
104
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
* Remove CSS import errors:
|
|
106
|
+
*
|
|
107
|
+
* Jest failed to parse a file. This happens e.g. when your code or its
|
|
108
|
+
* dependencies use non-standard JavaScript syntax, or when Jest is not
|
|
109
|
+
* configured to support such syntax.
|
|
110
|
+
*/
|
|
107
111
|
"\\.(css|less|scss|sass)$": "identity-obj-proxy"
|
|
108
112
|
}
|
|
109
113
|
};
|
|
@@ -147,10 +151,10 @@ var prettierConfig = configCreator(defaultConfig5);
|
|
|
147
151
|
var defaultConfig6 = {
|
|
148
152
|
dependencyTypes: ["dev", "overrides",
|
|
149
153
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
* Exclude peer dependencies from the list of dependencies to check
|
|
155
|
+
* to avoid updating peer dependencies to the latest version, as updating
|
|
156
|
+
* React to the latest version instead >=16.8.0.
|
|
157
|
+
*/
|
|
154
158
|
// 'peer',
|
|
155
159
|
"pnpmOverrides", "prod", "resolutions"],
|
|
156
160
|
filter: ".",
|
|
@@ -163,6 +167,9 @@ var defaultConfig6 = {
|
|
|
163
167
|
};
|
|
164
168
|
var syncpackConfig = configCreator(defaultConfig6);
|
|
165
169
|
|
|
170
|
+
// src/tsup.ts
|
|
171
|
+
import { transformAsync } from "@babel/core";
|
|
172
|
+
|
|
166
173
|
// src/typescriptConfig.ts
|
|
167
174
|
var typescriptConfig_exports = {};
|
|
168
175
|
__export(typescriptConfig_exports, {
|
|
@@ -171,10 +178,9 @@ __export(typescriptConfig_exports, {
|
|
|
171
178
|
var target = "es2023";
|
|
172
179
|
|
|
173
180
|
// src/tsup.ts
|
|
174
|
-
import { transformAsync } from "@babel/core";
|
|
175
181
|
var formatjsPlugin = {
|
|
176
182
|
name: "formatjs",
|
|
177
|
-
setup: build => {
|
|
183
|
+
setup: /* @__PURE__ */__name(build => {
|
|
178
184
|
build.onEnd(async result => {
|
|
179
185
|
await Promise.all((result.outputFiles || []).map(async outputFile => {
|
|
180
186
|
if (!outputFile.path.endsWith(".js") && !outputFile.path.endsWith(".mjs") && !outputFile.path.endsWith(".cjs")) {
|
|
@@ -196,25 +202,65 @@ var formatjsPlugin = {
|
|
|
196
202
|
}
|
|
197
203
|
}));
|
|
198
204
|
});
|
|
199
|
-
}
|
|
205
|
+
}, "setup")
|
|
200
206
|
};
|
|
207
|
+
var injectReactImport = /* @__PURE__ */__name(() => {
|
|
208
|
+
return {
|
|
209
|
+
name: "@ttoss/esbuild-inject-react-import",
|
|
210
|
+
setup: /* @__PURE__ */__name(build => {
|
|
211
|
+
build.onEnd(result => {
|
|
212
|
+
if (result.outputFiles) {
|
|
213
|
+
for (const outputFile of result.outputFiles) {
|
|
214
|
+
if (outputFile.path.endsWith(".js")) {
|
|
215
|
+
let contents = outputFile.text;
|
|
216
|
+
const usesReact = /React\./.test(contents);
|
|
217
|
+
if (usesReact) {
|
|
218
|
+
const hasBasicReactImport = /import\s+\*\s+as\s+React\s+from\s+['"]react['"]/.test(contents);
|
|
219
|
+
if (!hasBasicReactImport) {
|
|
220
|
+
const bannerMatch = contents.match(/^((?:\/\/[^\n]*\n|\/\*[^]*?\*\/)\s*)*/);
|
|
221
|
+
const insertPosition = bannerMatch ? bannerMatch[0].length : 0;
|
|
222
|
+
const isESM = /\bimport\b|\bexport\b/.test(contents);
|
|
223
|
+
const isCJS = /\brequire\(|module\.exports\b/.test(contents);
|
|
224
|
+
const importStatement = (() => {
|
|
225
|
+
if (isESM && !isCJS) {
|
|
226
|
+
return `import * as React from 'react';
|
|
227
|
+
`;
|
|
228
|
+
} else if (isCJS && !isESM) {
|
|
229
|
+
return `const React = require('react');
|
|
230
|
+
`;
|
|
231
|
+
} else {
|
|
232
|
+
return `import * as React from 'react';
|
|
233
|
+
`;
|
|
234
|
+
}
|
|
235
|
+
})();
|
|
236
|
+
contents = contents.slice(0, insertPosition) + importStatement + contents.slice(insertPosition);
|
|
237
|
+
outputFile.contents = new TextEncoder().encode(contents);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}, "setup")
|
|
245
|
+
};
|
|
246
|
+
}, "injectReactImport");
|
|
201
247
|
var defaultConfig7 = {
|
|
202
248
|
clean: true,
|
|
203
249
|
dts: true,
|
|
204
250
|
entryPoints: ["src/index.ts"],
|
|
205
251
|
format: ["cjs", "esm"],
|
|
206
252
|
/**
|
|
207
|
-
|
|
208
|
-
|
|
253
|
+
* legacyOutput `true` because some libraries don't support `.mjs`.
|
|
254
|
+
*/
|
|
209
255
|
legacyOutput: true,
|
|
210
256
|
/**
|
|
211
|
-
|
|
212
|
-
|
|
257
|
+
* Becomes difficult to debug if code is minified.
|
|
258
|
+
*/
|
|
213
259
|
minify: false,
|
|
214
260
|
banner: {
|
|
215
261
|
js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`
|
|
216
262
|
},
|
|
217
|
-
esbuildPlugins: [formatjsPlugin],
|
|
263
|
+
esbuildPlugins: [formatjsPlugin, injectReactImport()],
|
|
218
264
|
target
|
|
219
265
|
};
|
|
220
266
|
var tsupConfig = configCreator(defaultConfig7);
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __name = (target2, value) => __defProp(target2, "name", {
|
|
11
|
+
value,
|
|
12
|
+
configurable: true
|
|
13
|
+
});
|
|
10
14
|
var __commonJS = (cb, mod) => function __require() {
|
|
11
15
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
|
|
12
16
|
exports: {}
|
|
@@ -56,25 +60,25 @@ var require_babel_config = __commonJS({
|
|
|
56
60
|
}]],
|
|
57
61
|
plugins: [
|
|
58
62
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
* Carlin is full ESM and jest doesn't support import.meta.url from
|
|
64
|
+
* @ttoss/cloudformation. This plugin is needed to transform import.meta.url
|
|
65
|
+
*
|
|
66
|
+
* More reference about pure ESM packages:
|
|
67
|
+
* https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
|
68
|
+
*/
|
|
65
69
|
"babel-plugin-transform-import-meta",
|
|
66
70
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
* This plugin is needed to create a unique ID for each message in the
|
|
72
|
+
* translation files.
|
|
73
|
+
*/
|
|
70
74
|
["formatjs", {
|
|
71
75
|
idInterpolationPattern: "[sha512:contenthash:base64:6]",
|
|
72
76
|
ast: true
|
|
73
77
|
}],
|
|
74
78
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
* Decorators are not supported in ES6, so we need to use this plugin to
|
|
80
|
+
* transpile decorators to ES5.
|
|
81
|
+
*/
|
|
78
82
|
["@babel/plugin-proposal-decorators", {
|
|
79
83
|
version: "legacy"
|
|
80
84
|
}]]
|
|
@@ -101,16 +105,16 @@ module.exports = __toCommonJS(index_exports);
|
|
|
101
105
|
|
|
102
106
|
// src/configCreator.ts
|
|
103
107
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
104
|
-
var overwriteMerge = (_, sourceArray) => {
|
|
108
|
+
var overwriteMerge = /* @__PURE__ */__name((_, sourceArray) => {
|
|
105
109
|
return sourceArray;
|
|
106
|
-
};
|
|
107
|
-
var configCreator = (defaultConfig8 = {}) => {
|
|
110
|
+
}, "overwriteMerge");
|
|
111
|
+
var configCreator = /* @__PURE__ */__name((defaultConfig8 = {}) => {
|
|
108
112
|
return (config = {}, deepmergeConfig) => {
|
|
109
113
|
return (0, import_deepmerge.default)(defaultConfig8, config, {
|
|
110
114
|
arrayMerge: deepmergeConfig?.arrayMerge === "overwrite" ? overwriteMerge : void 0
|
|
111
115
|
});
|
|
112
116
|
};
|
|
113
|
-
};
|
|
117
|
+
}, "configCreator");
|
|
114
118
|
|
|
115
119
|
// src/babel.ts
|
|
116
120
|
var defaultConfig = require_babel_config();
|
|
@@ -129,25 +133,25 @@ var defaultConfig3 = {
|
|
|
129
133
|
coverageDirectory: "coverage",
|
|
130
134
|
coverageProvider: "babel",
|
|
131
135
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
* https://github.com/jestjs/jest/issues/13739#issuecomment-1517190965
|
|
137
|
+
*/
|
|
134
138
|
extensionsToTreatAsEsm: [".ts", ".tsx"],
|
|
135
139
|
fakeTimers: {
|
|
136
140
|
advanceTimers: true,
|
|
137
141
|
enableGlobally: true
|
|
138
142
|
},
|
|
139
143
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
* https://stackoverflow.com/a/64390115/8786986
|
|
145
|
+
*/
|
|
142
146
|
moduleDirectories: ["node_modules", "<rootDir>/../.."],
|
|
143
147
|
moduleNameMapper: {
|
|
144
148
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
* Remove CSS import errors:
|
|
150
|
+
*
|
|
151
|
+
* Jest failed to parse a file. This happens e.g. when your code or its
|
|
152
|
+
* dependencies use non-standard JavaScript syntax, or when Jest is not
|
|
153
|
+
* configured to support such syntax.
|
|
154
|
+
*/
|
|
151
155
|
"\\.(css|less|scss|sass)$": "identity-obj-proxy"
|
|
152
156
|
}
|
|
153
157
|
};
|
|
@@ -191,10 +195,10 @@ var prettierConfig = configCreator(defaultConfig5);
|
|
|
191
195
|
var defaultConfig6 = {
|
|
192
196
|
dependencyTypes: ["dev", "overrides",
|
|
193
197
|
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
* Exclude peer dependencies from the list of dependencies to check
|
|
199
|
+
* to avoid updating peer dependencies to the latest version, as updating
|
|
200
|
+
* React to the latest version instead >=16.8.0.
|
|
201
|
+
*/
|
|
198
202
|
// 'peer',
|
|
199
203
|
"pnpmOverrides", "prod", "resolutions"],
|
|
200
204
|
filter: ".",
|
|
@@ -207,6 +211,9 @@ var defaultConfig6 = {
|
|
|
207
211
|
};
|
|
208
212
|
var syncpackConfig = configCreator(defaultConfig6);
|
|
209
213
|
|
|
214
|
+
// src/tsup.ts
|
|
215
|
+
var import_core = require("@babel/core");
|
|
216
|
+
|
|
210
217
|
// src/typescriptConfig.ts
|
|
211
218
|
var typescriptConfig_exports = {};
|
|
212
219
|
__export(typescriptConfig_exports, {
|
|
@@ -215,10 +222,9 @@ __export(typescriptConfig_exports, {
|
|
|
215
222
|
var target = "es2023";
|
|
216
223
|
|
|
217
224
|
// src/tsup.ts
|
|
218
|
-
var import_core = require("@babel/core");
|
|
219
225
|
var formatjsPlugin = {
|
|
220
226
|
name: "formatjs",
|
|
221
|
-
setup: build => {
|
|
227
|
+
setup: /* @__PURE__ */__name(build => {
|
|
222
228
|
build.onEnd(async result => {
|
|
223
229
|
await Promise.all((result.outputFiles || []).map(async outputFile => {
|
|
224
230
|
if (!outputFile.path.endsWith(".js") && !outputFile.path.endsWith(".mjs") && !outputFile.path.endsWith(".cjs")) {
|
|
@@ -240,25 +246,65 @@ var formatjsPlugin = {
|
|
|
240
246
|
}
|
|
241
247
|
}));
|
|
242
248
|
});
|
|
243
|
-
}
|
|
249
|
+
}, "setup")
|
|
244
250
|
};
|
|
251
|
+
var injectReactImport = /* @__PURE__ */__name(() => {
|
|
252
|
+
return {
|
|
253
|
+
name: "@ttoss/esbuild-inject-react-import",
|
|
254
|
+
setup: /* @__PURE__ */__name(build => {
|
|
255
|
+
build.onEnd(result => {
|
|
256
|
+
if (result.outputFiles) {
|
|
257
|
+
for (const outputFile of result.outputFiles) {
|
|
258
|
+
if (outputFile.path.endsWith(".js")) {
|
|
259
|
+
let contents = outputFile.text;
|
|
260
|
+
const usesReact = /React\./.test(contents);
|
|
261
|
+
if (usesReact) {
|
|
262
|
+
const hasBasicReactImport = /import\s+\*\s+as\s+React\s+from\s+['"]react['"]/.test(contents);
|
|
263
|
+
if (!hasBasicReactImport) {
|
|
264
|
+
const bannerMatch = contents.match(/^((?:\/\/[^\n]*\n|\/\*[^]*?\*\/)\s*)*/);
|
|
265
|
+
const insertPosition = bannerMatch ? bannerMatch[0].length : 0;
|
|
266
|
+
const isESM = /\bimport\b|\bexport\b/.test(contents);
|
|
267
|
+
const isCJS = /\brequire\(|module\.exports\b/.test(contents);
|
|
268
|
+
const importStatement = (() => {
|
|
269
|
+
if (isESM && !isCJS) {
|
|
270
|
+
return `import * as React from 'react';
|
|
271
|
+
`;
|
|
272
|
+
} else if (isCJS && !isESM) {
|
|
273
|
+
return `const React = require('react');
|
|
274
|
+
`;
|
|
275
|
+
} else {
|
|
276
|
+
return `import * as React from 'react';
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
})();
|
|
280
|
+
contents = contents.slice(0, insertPosition) + importStatement + contents.slice(insertPosition);
|
|
281
|
+
outputFile.contents = new TextEncoder().encode(contents);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}, "setup")
|
|
289
|
+
};
|
|
290
|
+
}, "injectReactImport");
|
|
245
291
|
var defaultConfig7 = {
|
|
246
292
|
clean: true,
|
|
247
293
|
dts: true,
|
|
248
294
|
entryPoints: ["src/index.ts"],
|
|
249
295
|
format: ["cjs", "esm"],
|
|
250
296
|
/**
|
|
251
|
-
|
|
252
|
-
|
|
297
|
+
* legacyOutput `true` because some libraries don't support `.mjs`.
|
|
298
|
+
*/
|
|
253
299
|
legacyOutput: true,
|
|
254
300
|
/**
|
|
255
|
-
|
|
256
|
-
|
|
301
|
+
* Becomes difficult to debug if code is minified.
|
|
302
|
+
*/
|
|
257
303
|
minify: false,
|
|
258
304
|
banner: {
|
|
259
305
|
js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`
|
|
260
306
|
},
|
|
261
|
-
esbuildPlugins: [formatjsPlugin],
|
|
307
|
+
esbuildPlugins: [formatjsPlugin, injectReactImport()],
|
|
262
308
|
target
|
|
263
309
|
};
|
|
264
310
|
var tsupConfig = configCreator(defaultConfig7);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/config",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.7",
|
|
4
4
|
"description": "Default configuration for packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@jest/types": "^30.0.1",
|
|
40
40
|
"@types/jest": "^30.0.0",
|
|
41
41
|
"@types/node": "^22.15.32",
|
|
42
|
-
"esbuild": "^0.25.
|
|
42
|
+
"esbuild": "^0.25.8",
|
|
43
43
|
"jest": "^30.0.4",
|
|
44
44
|
"tsup": "^8.5.0"
|
|
45
45
|
},
|