@workleap/swc-configs 1.0.0 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
1
  # @workleap/swc-configs
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#92](https://github.com/gsoft-inc/wl-web-configs/pull/92) [`66e8f10`](https://github.com/gsoft-inc/wl-web-configs/commit/66e8f1033a987523c65fe9e61f53dac6d2e38777) Thanks [@ofrogon](https://github.com/ofrogon)! - Migrate project from GitHub organization
8
+
3
9
  ## 1.0.0
4
10
 
5
11
  ### Major Changes
6
12
 
7
- - [#85](https://github.com/workleap/wl-web-configs/pull/85) [`bad2df7`](https://github.com/workleap/wl-web-configs/commit/bad2df75593fb70d431d73bdced653b157c50caa) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated TSUP configuration and added a new SWC config package
13
+ - [#85](https://github.com/gsoft-inc/wl-web-configs/pull/85) [`bad2df7`](https://github.com/gsoft-inc/wl-web-configs/commit/bad2df75593fb70d431d73bdced653b157c50caa) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated TSUP configuration and added a new SWC config package
package/README.md CHANGED
@@ -391,7 +391,7 @@ Using a function allow the consumer to receive as argument a configuration objec
391
391
 
392
392
  ### CJS support
393
393
 
394
- To support CJS projects, the package is build for ESM and CJS formats. To support CJS, `type: "module"` has been temporary removed from the `package.json` file.
394
+ To support CJS projects, this package is build for ESM and CJS formats. To support CJS, `type: "module"` has been temporary removed from the `package.json` file.
395
395
 
396
396
  Once all our projects use ESM, CJS support can be removed.
397
397
 
@@ -0,0 +1,9 @@
1
+ import { Config } from '@swc/core';
2
+
3
+ interface SwcConfigTransformerContext {
4
+ environment: "dev" | "build" | "jest";
5
+ }
6
+ type SwcConfigTransformer = (config: Config, context: SwcConfigTransformerContext) => Config;
7
+ declare function applyTransformers(config: Config, transformers: SwcConfigTransformer[], context: SwcConfigTransformerContext): Config;
8
+
9
+ export { SwcConfigTransformer, SwcConfigTransformerContext, applyTransformers };
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ // src/applyTransformers.ts
4
+ function applyTransformers(config, transformers, context) {
5
+ return transformers.reduce((acc, transformer) => transformer(acc, context), config);
6
+ }
7
+
8
+ exports.applyTransformers = applyTransformers;
@@ -0,0 +1 @@
1
+ export { applyTransformers } from './chunk-3UBBOKDF.mjs';
package/dist/build.d.ts CHANGED
@@ -1,35 +1,11 @@
1
1
  import { Config } from '@swc/core';
2
- import { ConfigOverride } from './resolveOverrides.js';
2
+ import { SwcConfigTransformer } from './applyTransformers.js';
3
3
 
4
- declare const DefaultBuildConfig: {
5
- jsc: {
6
- parser: {
7
- syntax: "typescript";
8
- tsx: true;
9
- };
10
- target: "es2022";
11
- minify: {
12
- compress: true;
13
- mangle: true;
14
- };
15
- transform: {
16
- react: {
17
- runtime: "automatic";
18
- useBuiltins: true;
19
- };
20
- };
21
- externalHelpers: true;
22
- };
23
- module: {
24
- type: "es6";
25
- strict: true;
26
- ignoreDynamic: true;
27
- };
28
- };
29
4
  interface DefineBuildConfigOptions {
30
- parser?: "ecmascript";
31
- configOverride?: ConfigOverride;
5
+ browsers: any;
6
+ parser?: "ecmascript" | "typescript";
7
+ transformers?: SwcConfigTransformer[];
32
8
  }
33
- declare function defineBuildConfig({ parser, configOverride }?: DefineBuildConfigOptions): Config;
9
+ declare function defineBuildConfig(options: DefineBuildConfigOptions): Config;
34
10
 
35
- export { DefaultBuildConfig, DefineBuildConfigOptions, defineBuildConfig };
11
+ export { DefineBuildConfigOptions, defineBuildConfig };
package/dist/build.js CHANGED
@@ -1,72 +1,61 @@
1
1
  'use strict';
2
2
 
3
- // src/cloneObjectExceptFunctions.ts
4
- function cloneObjectExceptFunctions(obj) {
5
- return JSON.parse(JSON.stringify(obj));
6
- }
7
-
8
- // src/resolveOverrides.ts
9
- function resolveOverrides(config, configOverride) {
10
- if (typeof configOverride === "function") {
11
- return {
12
- ...config,
13
- ...configOverride(config)
14
- };
15
- }
16
- if (configOverride) {
17
- return {
18
- ...config,
19
- ...configOverride
20
- };
21
- }
22
- return config;
3
+ // src/applyTransformers.ts
4
+ function applyTransformers(config, transformers, context) {
5
+ return transformers.reduce((acc, transformer) => transformer(acc, context), config);
23
6
  }
24
7
 
25
8
  // src/build.ts
26
- var DefaultBuildConfig = {
27
- jsc: {
28
- parser: {
29
- syntax: "typescript",
30
- tsx: true
31
- },
32
- // The output environment that the code will be compiled for.
33
- target: "es2022",
34
- // View https://swc.rs/docs/configuration/minification for options.
35
- minify: {
36
- compress: true,
37
- mangle: true
9
+ function defineBuildConfig(options) {
10
+ const {
11
+ browsers,
12
+ parser = "typescript",
13
+ transformers = []
14
+ } = options;
15
+ const config = {
16
+ jsc: {
17
+ parser: parser === "ecmascript" ? {
18
+ syntax: "ecmascript",
19
+ jsx: true
20
+ } : {
21
+ syntax: "typescript",
22
+ tsx: true
23
+ },
24
+ // The output environment that the code will be compiled for.
25
+ target: "es2022",
26
+ // View https://swc.rs/docs/configuration/minification for options.
27
+ minify: {
28
+ compress: true,
29
+ mangle: true
30
+ },
31
+ transform: {
32
+ react: {
33
+ // Use "react/jsx-runtime".
34
+ runtime: "automatic",
35
+ // Use the native "Object.assign()" instead of "_extends".
36
+ useBuiltins: true
37
+ }
38
+ },
39
+ // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
40
+ // Requires to add "@swc/helpers" as a project dependency.
41
+ externalHelpers: true
38
42
  },
39
- transform: {
40
- react: {
41
- // Use "react/jsx-runtime".
42
- runtime: "automatic",
43
- // Use the native "Object.assign()" instead of "_extends".
44
- useBuiltins: true
45
- }
43
+ module: {
44
+ // The output module resolution system that the code will be compiled for.
45
+ type: "es6",
46
+ // Prevent SWC from exporting the `__esModule` property.
47
+ strict: true,
48
+ // Preserve dynamic imports.
49
+ ignoreDynamic: true
46
50
  },
47
- // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
48
- // Requires to add "@swc/helpers" as a project dependency
49
- externalHelpers: true
50
- },
51
- module: {
52
- // The output module resolution system that the code will be compiled for.
53
- type: "es6",
54
- // Prevent SWC from exporting the `__esModule` property.
55
- strict: true,
56
- // Preserve dynamic imports.
57
- ignoreDynamic: true
58
- }
59
- };
60
- function defineBuildConfig({ parser, configOverride } = {}) {
61
- const config = cloneObjectExceptFunctions(DefaultBuildConfig);
62
- if (parser === "ecmascript") {
63
- config.jsc.parser = {
64
- syntax: "ecmascript",
65
- jsx: true
66
- };
67
- }
68
- return resolveOverrides(config, configOverride);
51
+ env: {
52
+ targets: browsers
53
+ }
54
+ };
55
+ const transformedConfig = applyTransformers(config, transformers, {
56
+ environment: "build"
57
+ });
58
+ return transformedConfig;
69
59
  }
70
60
 
71
- exports.DefaultBuildConfig = DefaultBuildConfig;
72
61
  exports.defineBuildConfig = defineBuildConfig;
package/dist/build.mjs CHANGED
@@ -1,3 +1,2 @@
1
- export { DefaultBuildConfig, defineBuildConfig } from './chunk-JW562DWU.mjs';
2
- import './chunk-XCGQZSNA.mjs';
3
- import './chunk-4LXCYXR5.mjs';
1
+ export { defineBuildConfig } from './chunk-UFEY2RGG.mjs';
2
+ import './chunk-3UBBOKDF.mjs';
@@ -0,0 +1,6 @@
1
+ // src/applyTransformers.ts
2
+ function applyTransformers(config, transformers, context) {
3
+ return transformers.reduce((acc, transformer) => transformer(acc, context), config);
4
+ }
5
+
6
+ export { applyTransformers };
@@ -0,0 +1,45 @@
1
+ import { applyTransformers } from './chunk-3UBBOKDF.mjs';
2
+
3
+ // src/jest.ts
4
+ function defineJestConfig(options = {}) {
5
+ const {
6
+ react = false,
7
+ parser = "typescript",
8
+ transformers = []
9
+ } = options;
10
+ const config = {
11
+ jsc: {
12
+ parser: parser === "ecmascript" ? {
13
+ syntax: "ecmascript",
14
+ jsx: react
15
+ } : {
16
+ syntax: "typescript",
17
+ tsx: react
18
+ },
19
+ // The output environment that the code will be compiled for.
20
+ target: "es2022",
21
+ transform: react ? {
22
+ react: {
23
+ // Use "react/jsx-runtime".
24
+ runtime: "automatic",
25
+ // Use the native "Object.assign()" instead of "_extends".
26
+ useBuiltins: true
27
+ }
28
+ } : void 0
29
+ },
30
+ module: {
31
+ // The output module resolution system that the code will be compiled for.
32
+ type: "es6",
33
+ // Prevent SWC from exporting the `__esModule` property.
34
+ strict: true,
35
+ // Preserve dynamic imports.
36
+ ignoreDynamic: true
37
+ }
38
+ };
39
+ const transformedConfig = applyTransformers(config, transformers, {
40
+ environment: "jest"
41
+ });
42
+ return transformedConfig;
43
+ }
44
+
45
+ export { defineJestConfig };
@@ -0,0 +1,55 @@
1
+ import { applyTransformers } from './chunk-3UBBOKDF.mjs';
2
+
3
+ // src/dev.ts
4
+ function defineDevConfig(options) {
5
+ const {
6
+ browsers,
7
+ fastRefresh = false,
8
+ parser = "typescript",
9
+ transformers = []
10
+ } = options;
11
+ const config = {
12
+ jsc: {
13
+ parser: parser === "ecmascript" ? {
14
+ syntax: "ecmascript",
15
+ jsx: true
16
+ } : {
17
+ syntax: "typescript",
18
+ tsx: true
19
+ },
20
+ // The output environment that the code will be compiled for.
21
+ target: "es2022",
22
+ transform: {
23
+ react: {
24
+ // Use "react/jsx-runtime".
25
+ runtime: "automatic",
26
+ // Use the native "Object.assign()" instead of "_extends".
27
+ useBuiltins: true,
28
+ // Enable React experimental "fast-refresh" feature.
29
+ // Also need to install @pmmmwh/react-refresh-webpack-plugin.
30
+ refresh: fastRefresh
31
+ }
32
+ },
33
+ // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
34
+ // Requires to add "@swc/helpers" as a project dependency.
35
+ externalHelpers: true
36
+ },
37
+ module: {
38
+ // The output module resolution system that the code will be compiled for.
39
+ type: "es6",
40
+ // Prevent SWC from exporting the `__esModule` property.
41
+ strict: true,
42
+ // Preserve dynamic imports.
43
+ ignoreDynamic: true
44
+ },
45
+ env: {
46
+ targets: browsers
47
+ }
48
+ };
49
+ const transformedConfig = applyTransformers(config, transformers, {
50
+ environment: "dev"
51
+ });
52
+ return transformedConfig;
53
+ }
54
+
55
+ export { defineDevConfig };
@@ -0,0 +1,56 @@
1
+ import { applyTransformers } from './chunk-3UBBOKDF.mjs';
2
+
3
+ // src/build.ts
4
+ function defineBuildConfig(options) {
5
+ const {
6
+ browsers,
7
+ parser = "typescript",
8
+ transformers = []
9
+ } = options;
10
+ const config = {
11
+ jsc: {
12
+ parser: parser === "ecmascript" ? {
13
+ syntax: "ecmascript",
14
+ jsx: true
15
+ } : {
16
+ syntax: "typescript",
17
+ tsx: true
18
+ },
19
+ // The output environment that the code will be compiled for.
20
+ target: "es2022",
21
+ // View https://swc.rs/docs/configuration/minification for options.
22
+ minify: {
23
+ compress: true,
24
+ mangle: true
25
+ },
26
+ transform: {
27
+ react: {
28
+ // Use "react/jsx-runtime".
29
+ runtime: "automatic",
30
+ // Use the native "Object.assign()" instead of "_extends".
31
+ useBuiltins: true
32
+ }
33
+ },
34
+ // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
35
+ // Requires to add "@swc/helpers" as a project dependency.
36
+ externalHelpers: true
37
+ },
38
+ module: {
39
+ // The output module resolution system that the code will be compiled for.
40
+ type: "es6",
41
+ // Prevent SWC from exporting the `__esModule` property.
42
+ strict: true,
43
+ // Preserve dynamic imports.
44
+ ignoreDynamic: true
45
+ },
46
+ env: {
47
+ targets: browsers
48
+ }
49
+ };
50
+ const transformedConfig = applyTransformers(config, transformers, {
51
+ environment: "build"
52
+ });
53
+ return transformedConfig;
54
+ }
55
+
56
+ export { defineBuildConfig };
package/dist/dev.d.ts CHANGED
@@ -1,33 +1,12 @@
1
1
  import { Config } from '@swc/core';
2
- import { ConfigOverride } from './resolveOverrides.js';
2
+ import { SwcConfigTransformer } from './applyTransformers.js';
3
3
 
4
- declare const DefaultDevConfig: {
5
- jsc: {
6
- parser: {
7
- syntax: "typescript";
8
- tsx: true;
9
- };
10
- target: "es2022";
11
- transform: {
12
- react: {
13
- runtime: "automatic";
14
- useBuiltins: true;
15
- refresh: false;
16
- };
17
- };
18
- externalHelpers: true;
19
- };
20
- module: {
21
- type: "es6";
22
- strict: true;
23
- ignoreDynamic: true;
24
- };
25
- };
26
4
  interface DefineDevConfigOptions {
5
+ browsers: any;
27
6
  fastRefresh?: boolean;
28
- parser?: "ecmascript";
29
- configOverride?: ConfigOverride;
7
+ parser?: "ecmascript" | "typescript";
8
+ transformers?: SwcConfigTransformer[];
30
9
  }
31
- declare function defineDevConfig({ fastRefresh, parser, configOverride }?: DefineDevConfigOptions): Config;
10
+ declare function defineDevConfig(options: DefineDevConfigOptions): Config;
32
11
 
33
- export { DefaultDevConfig, DefineDevConfigOptions, defineDevConfig };
12
+ export { DefineDevConfigOptions, defineDevConfig };
package/dist/dev.js CHANGED
@@ -1,73 +1,60 @@
1
1
  'use strict';
2
2
 
3
- // src/cloneObjectExceptFunctions.ts
4
- function cloneObjectExceptFunctions(obj) {
5
- return JSON.parse(JSON.stringify(obj));
6
- }
7
-
8
- // src/resolveOverrides.ts
9
- function resolveOverrides(config, configOverride) {
10
- if (typeof configOverride === "function") {
11
- return {
12
- ...config,
13
- ...configOverride(config)
14
- };
15
- }
16
- if (configOverride) {
17
- return {
18
- ...config,
19
- ...configOverride
20
- };
21
- }
22
- return config;
3
+ // src/applyTransformers.ts
4
+ function applyTransformers(config, transformers, context) {
5
+ return transformers.reduce((acc, transformer) => transformer(acc, context), config);
23
6
  }
24
7
 
25
8
  // src/dev.ts
26
- var DefaultDevConfig = {
27
- jsc: {
28
- parser: {
29
- syntax: "typescript",
30
- tsx: true
9
+ function defineDevConfig(options) {
10
+ const {
11
+ browsers,
12
+ fastRefresh = false,
13
+ parser = "typescript",
14
+ transformers = []
15
+ } = options;
16
+ const config = {
17
+ jsc: {
18
+ parser: parser === "ecmascript" ? {
19
+ syntax: "ecmascript",
20
+ jsx: true
21
+ } : {
22
+ syntax: "typescript",
23
+ tsx: true
24
+ },
25
+ // The output environment that the code will be compiled for.
26
+ target: "es2022",
27
+ transform: {
28
+ react: {
29
+ // Use "react/jsx-runtime".
30
+ runtime: "automatic",
31
+ // Use the native "Object.assign()" instead of "_extends".
32
+ useBuiltins: true,
33
+ // Enable React experimental "fast-refresh" feature.
34
+ // Also need to install @pmmmwh/react-refresh-webpack-plugin.
35
+ refresh: fastRefresh
36
+ }
37
+ },
38
+ // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
39
+ // Requires to add "@swc/helpers" as a project dependency.
40
+ externalHelpers: true
31
41
  },
32
- // The output environment that the code will be compiled for.
33
- target: "es2022",
34
- transform: {
35
- react: {
36
- // Use "react/jsx-runtime".
37
- runtime: "automatic",
38
- // Use the native "Object.assign()" instead of "_extends".
39
- useBuiltins: true,
40
- // Enable React experimental "fast-refresh" feature.
41
- // Also need to install @pmmmwh/react-refresh-webpack-plugin.
42
- refresh: false
43
- }
42
+ module: {
43
+ // The output module resolution system that the code will be compiled for.
44
+ type: "es6",
45
+ // Prevent SWC from exporting the `__esModule` property.
46
+ strict: true,
47
+ // Preserve dynamic imports.
48
+ ignoreDynamic: true
44
49
  },
45
- // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
46
- // Requires to add "@swc/helpers" as a project dependency
47
- externalHelpers: true
48
- },
49
- module: {
50
- // The output module resolution system that the code will be compiled for.
51
- type: "es6",
52
- // Prevent SWC from exporting the `__esModule` property.
53
- strict: true,
54
- // Preserve dynamic imports.
55
- ignoreDynamic: true
56
- }
57
- };
58
- function defineDevConfig({ fastRefresh, parser, configOverride } = {}) {
59
- const config = cloneObjectExceptFunctions(DefaultDevConfig);
60
- if (fastRefresh) {
61
- config.jsc.transform.react.refresh = true;
62
- }
63
- if (parser === "ecmascript") {
64
- config.jsc.parser = {
65
- syntax: "ecmascript",
66
- jsx: true
67
- };
68
- }
69
- return resolveOverrides(config, configOverride);
50
+ env: {
51
+ targets: browsers
52
+ }
53
+ };
54
+ const transformedConfig = applyTransformers(config, transformers, {
55
+ environment: "dev"
56
+ });
57
+ return transformedConfig;
70
58
  }
71
59
 
72
- exports.DefaultDevConfig = DefaultDevConfig;
73
60
  exports.defineDevConfig = defineDevConfig;
package/dist/dev.mjs CHANGED
@@ -1,3 +1,2 @@
1
- export { DefaultDevConfig, defineDevConfig } from './chunk-4XYHUSOR.mjs';
2
- import './chunk-XCGQZSNA.mjs';
3
- import './chunk-4LXCYXR5.mjs';
1
+ export { defineDevConfig } from './chunk-LPGVRYUE.mjs';
2
+ import './chunk-3UBBOKDF.mjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { DefaultBuildConfig, DefineBuildConfigOptions, defineBuildConfig } from './build.js';
2
- export { DefaultDevConfig, DefineDevConfigOptions, defineDevConfig } from './dev.js';
3
- export { DefaultJestConfig, DefineJestConfigOptions, defineJestConfig } from './jest.js';
4
- export { ConfigOverride, ConfigOverrideFunction } from './resolveOverrides.js';
1
+ export { SwcConfigTransformer, SwcConfigTransformerContext } from './applyTransformers.js';
2
+ export { DefineBuildConfigOptions, defineBuildConfig } from './build.js';
3
+ export { DefineDevConfigOptions, defineDevConfig } from './dev.js';
4
+ export { DefineJestConfigOptions, defineJestConfig } from './jest.js';
5
5
  import '@swc/core';