@ttoss/config 1.35.6 → 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 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
- * Carlin is full ESM and jest doesn't support import.meta.url from
33
- * @ttoss/cloudformation. This plugin is needed to transform import.meta.url
34
- *
35
- * More reference about pure ESM packages:
36
- * https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
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
- * This plugin is needed to create a unique ID for each message in the
41
- * translation files.
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
- * Decorators are not supported in ES6, so we need to use this plugin to
49
- * transpile decorators to ES5.
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
- * https://github.com/jestjs/jest/issues/13739#issuecomment-1517190965
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
- * https://stackoverflow.com/a/64390115/8786986
97
- */
100
+ * https://stackoverflow.com/a/64390115/8786986
101
+ */
98
102
  moduleDirectories: ["node_modules", "<rootDir>/../.."],
99
103
  moduleNameMapper: {
100
104
  /**
101
- * Remove CSS import errors:
102
- *
103
- * Jest failed to parse a file. This happens e.g. when your code or its
104
- * dependencies use non-standard JavaScript syntax, or when Jest is not
105
- * configured to support such syntax.
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
- * Exclude peer dependencies from the list of dependencies to check
151
- * to avoid updating peer dependencies to the latest version, as updating
152
- * React to the latest version instead >=16.8.0.
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: ".",
@@ -176,7 +180,7 @@ var target = "es2023";
176
180
  // src/tsup.ts
177
181
  var formatjsPlugin = {
178
182
  name: "formatjs",
179
- setup: build => {
183
+ setup: /* @__PURE__ */__name(build => {
180
184
  build.onEnd(async result => {
181
185
  await Promise.all((result.outputFiles || []).map(async outputFile => {
182
186
  if (!outputFile.path.endsWith(".js") && !outputFile.path.endsWith(".mjs") && !outputFile.path.endsWith(".cjs")) {
@@ -198,25 +202,65 @@ var formatjsPlugin = {
198
202
  }
199
203
  }));
200
204
  });
201
- }
205
+ }, "setup")
202
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");
203
247
  var defaultConfig7 = {
204
248
  clean: true,
205
249
  dts: true,
206
250
  entryPoints: ["src/index.ts"],
207
251
  format: ["cjs", "esm"],
208
252
  /**
209
- * legacyOutput `true` because some libraries don't support `.mjs`.
210
- */
253
+ * legacyOutput `true` because some libraries don't support `.mjs`.
254
+ */
211
255
  legacyOutput: true,
212
256
  /**
213
- * Becomes difficult to debug if code is minified.
214
- */
257
+ * Becomes difficult to debug if code is minified.
258
+ */
215
259
  minify: false,
216
260
  banner: {
217
261
  js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`
218
262
  },
219
- esbuildPlugins: [formatjsPlugin],
263
+ esbuildPlugins: [formatjsPlugin, injectReactImport()],
220
264
  target
221
265
  };
222
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
- * Carlin is full ESM and jest doesn't support import.meta.url from
60
- * @ttoss/cloudformation. This plugin is needed to transform import.meta.url
61
- *
62
- * More reference about pure ESM packages:
63
- * https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
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
- * This plugin is needed to create a unique ID for each message in the
68
- * translation files.
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
- * Decorators are not supported in ES6, so we need to use this plugin to
76
- * transpile decorators to ES5.
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
- * https://github.com/jestjs/jest/issues/13739#issuecomment-1517190965
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
- * https://stackoverflow.com/a/64390115/8786986
141
- */
144
+ * https://stackoverflow.com/a/64390115/8786986
145
+ */
142
146
  moduleDirectories: ["node_modules", "<rootDir>/../.."],
143
147
  moduleNameMapper: {
144
148
  /**
145
- * Remove CSS import errors:
146
- *
147
- * Jest failed to parse a file. This happens e.g. when your code or its
148
- * dependencies use non-standard JavaScript syntax, or when Jest is not
149
- * configured to support such syntax.
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
- * Exclude peer dependencies from the list of dependencies to check
195
- * to avoid updating peer dependencies to the latest version, as updating
196
- * React to the latest version instead >=16.8.0.
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: ".",
@@ -220,7 +224,7 @@ var target = "es2023";
220
224
  // src/tsup.ts
221
225
  var formatjsPlugin = {
222
226
  name: "formatjs",
223
- setup: build => {
227
+ setup: /* @__PURE__ */__name(build => {
224
228
  build.onEnd(async result => {
225
229
  await Promise.all((result.outputFiles || []).map(async outputFile => {
226
230
  if (!outputFile.path.endsWith(".js") && !outputFile.path.endsWith(".mjs") && !outputFile.path.endsWith(".cjs")) {
@@ -242,25 +246,65 @@ var formatjsPlugin = {
242
246
  }
243
247
  }));
244
248
  });
245
- }
249
+ }, "setup")
246
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");
247
291
  var defaultConfig7 = {
248
292
  clean: true,
249
293
  dts: true,
250
294
  entryPoints: ["src/index.ts"],
251
295
  format: ["cjs", "esm"],
252
296
  /**
253
- * legacyOutput `true` because some libraries don't support `.mjs`.
254
- */
297
+ * legacyOutput `true` because some libraries don't support `.mjs`.
298
+ */
255
299
  legacyOutput: true,
256
300
  /**
257
- * Becomes difficult to debug if code is minified.
258
- */
301
+ * Becomes difficult to debug if code is minified.
302
+ */
259
303
  minify: false,
260
304
  banner: {
261
305
  js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`
262
306
  },
263
- esbuildPlugins: [formatjsPlugin],
307
+ esbuildPlugins: [formatjsPlugin, injectReactImport()],
264
308
  target
265
309
  };
266
310
  var tsupConfig = configCreator(defaultConfig7);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/config",
3
- "version": "1.35.6",
3
+ "version": "1.35.7",
4
4
  "description": "Default configuration for packages.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",