@ttoss/config 1.29.1 → 1.29.3

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
@@ -16,27 +16,26 @@ var configCreator = (defaultConfig7 = {}) => {
16
16
  // src/babel.ts
17
17
  var defaultConfig = {
18
18
  presets: [
19
- /**
20
- * `loose: true` to avoid the Storybook warning:
21
- *
22
- * > Though the "loose" option was set to "false" in your @babel/preset-env
23
- * > config, it will not be used for @babel/plugin-proposal-private-property-in-object
24
- * > since the "loose" mode option was set to "true"
25
- * > for @babel/plugin-proposal-private-methods.
26
- */
27
- ["@babel/preset-env", { loose: true, targets: { node: "current" } }],
28
- "@babel/preset-typescript",
29
- ["@babel/preset-react", { runtime: "automatic" }]
30
- ],
31
- plugins: [
32
- [
33
- "formatjs",
34
- {
35
- idInterpolationPattern: "[sha512:contenthash:base64:6]",
36
- ast: true
37
- }
38
- ]
39
- ]
19
+ /**
20
+ * `loose: true` to avoid the Storybook warning:
21
+ *
22
+ * > Though the "loose" option was set to "false" in your @babel/preset-env
23
+ * > config, it will not be used for @babel/plugin-proposal-private-property-in-object
24
+ * > since the "loose" mode option was set to "true"
25
+ * > for @babel/plugin-proposal-private-methods.
26
+ */
27
+ ["@babel/preset-env", {
28
+ loose: true,
29
+ targets: {
30
+ node: "current"
31
+ }
32
+ }], "@babel/preset-typescript", ["@babel/preset-react", {
33
+ runtime: "automatic"
34
+ }]],
35
+ plugins: [["formatjs", {
36
+ idInterpolationPattern: "[sha512:contenthash:base64:6]",
37
+ ast: true
38
+ }]]
40
39
  };
41
40
  var babelConfig = configCreator(defaultConfig);
42
41
 
@@ -87,6 +86,33 @@ var defaultConfig5 = {
87
86
  var prettierConfig = configCreator(defaultConfig5);
88
87
 
89
88
  // src/tsup.ts
89
+ import { transformAsync } from "@babel/core";
90
+ var formatjsPlugin = {
91
+ name: "formatjs",
92
+ setup: build => {
93
+ build.onEnd(async result => {
94
+ await Promise.all((result.outputFiles || []).map(async outputFile => {
95
+ if (!outputFile.path.endsWith(".js") && !outputFile.path.endsWith(".mjs") && !outputFile.path.endsWith(".cjs")) {
96
+ return;
97
+ }
98
+ const transformedFile = await transformAsync(outputFile.text, {
99
+ caller: {
100
+ name: "formatjs-transformer",
101
+ supportsStaticESM: true
102
+ },
103
+ filename: outputFile.path,
104
+ plugins: [["formatjs", {
105
+ idInterpolationPattern: "[sha512:contenthash:base64:6]",
106
+ ast: true
107
+ }]]
108
+ });
109
+ if (transformedFile?.code) {
110
+ outputFile.contents = Buffer.from(transformedFile.code);
111
+ }
112
+ }));
113
+ });
114
+ }
115
+ };
90
116
  var defaultConfig6 = {
91
117
  clean: true,
92
118
  dts: true,
@@ -102,14 +128,8 @@ var defaultConfig6 = {
102
128
  minify: false,
103
129
  banner: {
104
130
  js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`
105
- }
131
+ },
132
+ esbuildPlugins: [formatjsPlugin]
106
133
  };
107
134
  var tsupConfig = configCreator(defaultConfig6);
108
- export {
109
- babelConfig,
110
- commitlintConfig,
111
- jestConfig,
112
- lintstagedConfig,
113
- prettierConfig,
114
- tsupConfig
115
- };
135
+ export { babelConfig, commitlintConfig, jestConfig, lintstagedConfig, prettierConfig, tsupConfig };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
  "use strict";
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,26 +8,32 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
12
15
  };
13
16
  var __copyProps = (to, from, except, desc) => {
14
17
  if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
18
22
  }
19
23
  return to;
20
24
  };
21
25
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
+ value: mod,
32
+ enumerable: true
33
+ }) : target, mod));
34
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
35
+ value: true
36
+ }), mod);
30
37
 
31
38
  // src/index.ts
32
39
  var src_exports = {};
@@ -56,27 +63,26 @@ var configCreator = (defaultConfig7 = {}) => {
56
63
  // src/babel.ts
57
64
  var defaultConfig = {
58
65
  presets: [
59
- /**
60
- * `loose: true` to avoid the Storybook warning:
61
- *
62
- * > Though the "loose" option was set to "false" in your @babel/preset-env
63
- * > config, it will not be used for @babel/plugin-proposal-private-property-in-object
64
- * > since the "loose" mode option was set to "true"
65
- * > for @babel/plugin-proposal-private-methods.
66
- */
67
- ["@babel/preset-env", { loose: true, targets: { node: "current" } }],
68
- "@babel/preset-typescript",
69
- ["@babel/preset-react", { runtime: "automatic" }]
70
- ],
71
- plugins: [
72
- [
73
- "formatjs",
74
- {
75
- idInterpolationPattern: "[sha512:contenthash:base64:6]",
76
- ast: true
77
- }
78
- ]
79
- ]
66
+ /**
67
+ * `loose: true` to avoid the Storybook warning:
68
+ *
69
+ * > Though the "loose" option was set to "false" in your @babel/preset-env
70
+ * > config, it will not be used for @babel/plugin-proposal-private-property-in-object
71
+ * > since the "loose" mode option was set to "true"
72
+ * > for @babel/plugin-proposal-private-methods.
73
+ */
74
+ ["@babel/preset-env", {
75
+ loose: true,
76
+ targets: {
77
+ node: "current"
78
+ }
79
+ }], "@babel/preset-typescript", ["@babel/preset-react", {
80
+ runtime: "automatic"
81
+ }]],
82
+ plugins: [["formatjs", {
83
+ idInterpolationPattern: "[sha512:contenthash:base64:6]",
84
+ ast: true
85
+ }]]
80
86
  };
81
87
  var babelConfig = configCreator(defaultConfig);
82
88
 
@@ -127,6 +133,33 @@ var defaultConfig5 = {
127
133
  var prettierConfig = configCreator(defaultConfig5);
128
134
 
129
135
  // src/tsup.ts
136
+ var import_core = require("@babel/core");
137
+ var formatjsPlugin = {
138
+ name: "formatjs",
139
+ setup: build => {
140
+ build.onEnd(async result => {
141
+ await Promise.all((result.outputFiles || []).map(async outputFile => {
142
+ if (!outputFile.path.endsWith(".js") && !outputFile.path.endsWith(".mjs") && !outputFile.path.endsWith(".cjs")) {
143
+ return;
144
+ }
145
+ const transformedFile = await (0, import_core.transformAsync)(outputFile.text, {
146
+ caller: {
147
+ name: "formatjs-transformer",
148
+ supportsStaticESM: true
149
+ },
150
+ filename: outputFile.path,
151
+ plugins: [["formatjs", {
152
+ idInterpolationPattern: "[sha512:contenthash:base64:6]",
153
+ ast: true
154
+ }]]
155
+ });
156
+ if (transformedFile?.code) {
157
+ outputFile.contents = Buffer.from(transformedFile.code);
158
+ }
159
+ }));
160
+ });
161
+ }
162
+ };
130
163
  var defaultConfig6 = {
131
164
  clean: true,
132
165
  dts: true,
@@ -142,7 +175,8 @@ var defaultConfig6 = {
142
175
  minify: false,
143
176
  banner: {
144
177
  js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`
145
- }
178
+ },
179
+ esbuildPlugins: [formatjsPlugin]
146
180
  };
147
181
  var tsupConfig = configCreator(defaultConfig6);
148
182
  // Annotate the CommonJS export names for ESM import in node:
@@ -153,4 +187,4 @@ var tsupConfig = configCreator(defaultConfig6);
153
187
  lintstagedConfig,
154
188
  prettierConfig,
155
189
  tsupConfig
156
- });
190
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/config",
3
- "version": "1.29.1",
3
+ "version": "1.29.3",
4
4
  "description": "Default configuration for packages.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ttoss",
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "typings": "dist/index.d.ts",
22
22
  "dependencies": {
23
+ "@babel/core": "^7.21.4",
23
24
  "@babel/preset-env": "^7.20.2",
24
25
  "@babel/preset-react": "^7.18.6",
25
26
  "@babel/preset-typescript": "^7.18.6",
@@ -39,5 +40,5 @@
39
40
  "publishConfig": {
40
41
  "access": "public"
41
42
  },
42
- "gitHead": "ee0c2e51d38f37f997c020d4303cf90be720ecb0"
43
+ "gitHead": "39abc27c77c2587edc8d877ccb121783611791a4"
43
44
  }
package/src/tsup.ts CHANGED
@@ -1,6 +1,48 @@
1
+ import { Plugin, PluginBuild } from 'esbuild';
1
2
  import { configCreator } from './configCreator';
3
+ import { transformAsync } from '@babel/core';
2
4
  import type { Options } from 'tsup';
3
5
 
6
+ const formatjsPlugin: Plugin = {
7
+ name: 'formatjs',
8
+ setup: (build: PluginBuild) => {
9
+ build.onEnd(async (result) => {
10
+ await Promise.all(
11
+ (result.outputFiles || []).map(async (outputFile) => {
12
+ if (
13
+ !outputFile.path.endsWith('.js') &&
14
+ !outputFile.path.endsWith('.mjs') &&
15
+ !outputFile.path.endsWith('.cjs')
16
+ ) {
17
+ return;
18
+ }
19
+
20
+ const transformedFile = await transformAsync(outputFile.text, {
21
+ caller: {
22
+ name: 'formatjs-transformer',
23
+ supportsStaticESM: true,
24
+ },
25
+ filename: outputFile.path,
26
+ plugins: [
27
+ [
28
+ 'formatjs',
29
+ {
30
+ idInterpolationPattern: '[sha512:contenthash:base64:6]',
31
+ ast: true,
32
+ },
33
+ ],
34
+ ],
35
+ });
36
+
37
+ if (transformedFile?.code) {
38
+ outputFile.contents = Buffer.from(transformedFile.code);
39
+ }
40
+ })
41
+ );
42
+ });
43
+ },
44
+ };
45
+
4
46
  export const defaultConfig: Options = {
5
47
  clean: true,
6
48
  dts: true,
@@ -17,6 +59,7 @@ export const defaultConfig: Options = {
17
59
  banner: {
18
60
  js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`,
19
61
  },
62
+ esbuildPlugins: [formatjsPlugin],
20
63
  };
21
64
 
22
65
  export const tsupConfig = configCreator(defaultConfig);