@workleap/swc-configs 0.0.1 → 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/dist/jest.js CHANGED
@@ -1,71 +1,50 @@
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/jest.ts
26
- var DefaultJestConfig = {
27
- jsc: {
28
- parser: {
29
- syntax: "typescript"
9
+ function defineJestConfig(options = {}) {
10
+ const {
11
+ react = false,
12
+ parser = "typescript",
13
+ transformers = []
14
+ } = options;
15
+ const config = {
16
+ jsc: {
17
+ parser: parser === "ecmascript" ? {
18
+ syntax: "ecmascript",
19
+ jsx: react
20
+ } : {
21
+ syntax: "typescript",
22
+ tsx: react
23
+ },
24
+ // The output environment that the code will be compiled for.
25
+ target: "es2022",
26
+ transform: react ? {
27
+ react: {
28
+ // Use "react/jsx-runtime".
29
+ runtime: "automatic",
30
+ // Use the native "Object.assign()" instead of "_extends".
31
+ useBuiltins: true
32
+ }
33
+ } : void 0
30
34
  },
31
- // The output environment that the code will be compiled for.
32
- target: "es2022",
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
- };
46
- function defineJestConfig({ react, parser, configOverride } = {}) {
47
- const config = cloneObjectExceptFunctions(DefaultJestConfig);
48
- if (react) {
49
- config.jsc.transform = {
50
- react: {
51
- // Use "react/jsx-runtime".
52
- runtime: "automatic",
53
- // Use the native "Object.assign()" instead of "_extends".
54
- useBuiltins: true
55
- }
56
- };
57
- }
58
- if (parser === "ecmascript") {
59
- const parserConfig = { syntax: "ecmascript" };
60
- if (react) {
61
- parserConfig.jsx = true;
35
+ module: {
36
+ // The output module resolution system that the code will be compiled for.
37
+ type: "es6",
38
+ // Prevent SWC from exporting the `__esModule` property.
39
+ strict: true,
40
+ // Preserve dynamic imports.
41
+ ignoreDynamic: true
62
42
  }
63
- config.jsc.parser = parserConfig;
64
- } else if (react) {
65
- config.jsc.parser.tsx = true;
66
- }
67
- return resolveOverrides(config, configOverride);
43
+ };
44
+ const transformedConfig = applyTransformers(config, transformers, {
45
+ environment: "jest"
46
+ });
47
+ return transformedConfig;
68
48
  }
69
49
 
70
- exports.DefaultJestConfig = DefaultJestConfig;
71
50
  exports.defineJestConfig = defineJestConfig;
package/dist/jest.mjs CHANGED
@@ -1,3 +1,2 @@
1
- export { DefaultJestConfig, defineJestConfig } from './chunk-5HQ4FWBC.mjs';
2
- import './chunk-XCGQZSNA.mjs';
3
- import './chunk-4LXCYXR5.mjs';
1
+ export { defineJestConfig } from './chunk-6PUKUTDM.mjs';
2
+ import './chunk-3UBBOKDF.mjs';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workleap/swc-configs",
3
3
  "description": "Workleap recommended SWC configs.",
4
- "version": "0.0.1",
4
+ "version": "1.0.1",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
7
7
  "workleap",
@@ -12,7 +12,8 @@
12
12
  ".": {
13
13
  "require": "./dist/index.js",
14
14
  "import": "./dist/index.mjs",
15
- "types": "./dist/index.d.ts"
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.mjs"
16
17
  }
17
18
  },
18
19
  "files": [
@@ -22,7 +23,7 @@
22
23
  ],
23
24
  "repository": {
24
25
  "type": "git",
25
- "url": "git+https://github.com/workleap/wl-web-configs.git",
26
+ "url": "git+https://github.com/gsoft-inc/wl-web-configs.git",
26
27
  "directory": "packages/swc-configs"
27
28
  },
28
29
  "devDependencies": {
@@ -34,9 +35,9 @@
34
35
  "ts-node": "10.9.1",
35
36
  "tsup": "6.7.0",
36
37
  "typescript": "5.0.4",
37
- "@workleap/eslint-plugin": "1.8.1",
38
- "@workleap/tsup-configs": "1.0.1",
39
- "@workleap/typescript-configs": "2.3.1"
38
+ "@workleap/eslint-plugin": "1.8.3",
39
+ "@workleap/tsup-configs": "2.0.1",
40
+ "@workleap/typescript-configs": "2.3.3"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "@swc/core": "*",
@@ -1,18 +0,0 @@
1
- // src/resolveOverrides.ts
2
- function resolveOverrides(config, configOverride) {
3
- if (typeof configOverride === "function") {
4
- return {
5
- ...config,
6
- ...configOverride(config)
7
- };
8
- }
9
- if (configOverride) {
10
- return {
11
- ...config,
12
- ...configOverride
13
- };
14
- }
15
- return config;
16
- }
17
-
18
- export { resolveOverrides };
@@ -1,51 +0,0 @@
1
- import { cloneObjectExceptFunctions } from './chunk-XCGQZSNA.mjs';
2
- import { resolveOverrides } from './chunk-4LXCYXR5.mjs';
3
-
4
- // src/dev.ts
5
- var DefaultDevConfig = {
6
- jsc: {
7
- parser: {
8
- syntax: "typescript",
9
- tsx: true
10
- },
11
- // The output environment that the code will be compiled for.
12
- target: "es2022",
13
- transform: {
14
- react: {
15
- // Use "react/jsx-runtime".
16
- runtime: "automatic",
17
- // Use the native "Object.assign()" instead of "_extends".
18
- useBuiltins: true,
19
- // Enable React experimental "fast-refresh" feature.
20
- // Also need to install @pmmmwh/react-refresh-webpack-plugin.
21
- refresh: false
22
- }
23
- },
24
- // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
25
- // Requires to add "@swc/helpers" as a project dependency
26
- externalHelpers: true
27
- },
28
- module: {
29
- // The output module resolution system that the code will be compiled for.
30
- type: "es6",
31
- // Prevent SWC from exporting the `__esModule` property.
32
- strict: true,
33
- // Preserve dynamic imports.
34
- ignoreDynamic: true
35
- }
36
- };
37
- function defineDevConfig({ fastRefresh, parser, configOverride } = {}) {
38
- const config = cloneObjectExceptFunctions(DefaultDevConfig);
39
- if (fastRefresh) {
40
- config.jsc.transform.react.refresh = true;
41
- }
42
- if (parser === "ecmascript") {
43
- config.jsc.parser = {
44
- syntax: "ecmascript",
45
- jsx: true
46
- };
47
- }
48
- return resolveOverrides(config, configOverride);
49
- }
50
-
51
- export { DefaultDevConfig, defineDevConfig };
@@ -1,49 +0,0 @@
1
- import { cloneObjectExceptFunctions } from './chunk-XCGQZSNA.mjs';
2
- import { resolveOverrides } from './chunk-4LXCYXR5.mjs';
3
-
4
- // src/jest.ts
5
- var DefaultJestConfig = {
6
- jsc: {
7
- parser: {
8
- syntax: "typescript"
9
- },
10
- // The output environment that the code will be compiled for.
11
- target: "es2022",
12
- // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
13
- // Requires to add "@swc/helpers" as a project dependency
14
- externalHelpers: true
15
- },
16
- module: {
17
- // The output module resolution system that the code will be compiled for.
18
- type: "es6",
19
- // Prevent SWC from exporting the `__esModule` property.
20
- strict: true,
21
- // Preserve dynamic imports.
22
- ignoreDynamic: true
23
- }
24
- };
25
- function defineJestConfig({ react, parser, configOverride } = {}) {
26
- const config = cloneObjectExceptFunctions(DefaultJestConfig);
27
- if (react) {
28
- config.jsc.transform = {
29
- react: {
30
- // Use "react/jsx-runtime".
31
- runtime: "automatic",
32
- // Use the native "Object.assign()" instead of "_extends".
33
- useBuiltins: true
34
- }
35
- };
36
- }
37
- if (parser === "ecmascript") {
38
- const parserConfig = { syntax: "ecmascript" };
39
- if (react) {
40
- parserConfig.jsx = true;
41
- }
42
- config.jsc.parser = parserConfig;
43
- } else if (react) {
44
- config.jsc.parser.tsx = true;
45
- }
46
- return resolveOverrides(config, configOverride);
47
- }
48
-
49
- export { DefaultJestConfig, defineJestConfig };
@@ -1,50 +0,0 @@
1
- import { cloneObjectExceptFunctions } from './chunk-XCGQZSNA.mjs';
2
- import { resolveOverrides } from './chunk-4LXCYXR5.mjs';
3
-
4
- // src/build.ts
5
- var DefaultBuildConfig = {
6
- jsc: {
7
- parser: {
8
- syntax: "typescript",
9
- tsx: true
10
- },
11
- // The output environment that the code will be compiled for.
12
- target: "es2022",
13
- // View https://swc.rs/docs/configuration/minification for options.
14
- minify: {
15
- compress: true,
16
- mangle: true
17
- },
18
- transform: {
19
- react: {
20
- // Use "react/jsx-runtime".
21
- runtime: "automatic",
22
- // Use the native "Object.assign()" instead of "_extends".
23
- useBuiltins: true
24
- }
25
- },
26
- // Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
27
- // Requires to add "@swc/helpers" as a project dependency
28
- externalHelpers: true
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
- function defineBuildConfig({ parser, configOverride } = {}) {
40
- const config = cloneObjectExceptFunctions(DefaultBuildConfig);
41
- if (parser === "ecmascript") {
42
- config.jsc.parser = {
43
- syntax: "ecmascript",
44
- jsx: true
45
- };
46
- }
47
- return resolveOverrides(config, configOverride);
48
- }
49
-
50
- export { DefaultBuildConfig, defineBuildConfig };
@@ -1,6 +0,0 @@
1
- // src/cloneObjectExceptFunctions.ts
2
- function cloneObjectExceptFunctions(obj) {
3
- return JSON.parse(JSON.stringify(obj));
4
- }
5
-
6
- export { cloneObjectExceptFunctions };
@@ -1,3 +0,0 @@
1
- declare function cloneObjectExceptFunctions<T>(obj: T): T;
2
-
3
- export { cloneObjectExceptFunctions };
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- // src/cloneObjectExceptFunctions.ts
4
- function cloneObjectExceptFunctions(obj) {
5
- return JSON.parse(JSON.stringify(obj));
6
- }
7
-
8
- exports.cloneObjectExceptFunctions = cloneObjectExceptFunctions;
@@ -1 +0,0 @@
1
- export { cloneObjectExceptFunctions } from './chunk-XCGQZSNA.mjs';
@@ -1,7 +0,0 @@
1
- import { Config } from '@swc/core';
2
-
3
- type ConfigOverrideFunction = (config: Config) => Config;
4
- type ConfigOverride = Config | ConfigOverrideFunction;
5
- declare function resolveOverrides(config: Config, configOverride?: ConfigOverride): Config;
6
-
7
- export { ConfigOverride, ConfigOverrideFunction, resolveOverrides };
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- // src/resolveOverrides.ts
4
- function resolveOverrides(config, configOverride) {
5
- if (typeof configOverride === "function") {
6
- return {
7
- ...config,
8
- ...configOverride(config)
9
- };
10
- }
11
- if (configOverride) {
12
- return {
13
- ...config,
14
- ...configOverride
15
- };
16
- }
17
- return config;
18
- }
19
-
20
- exports.resolveOverrides = resolveOverrides;
@@ -1 +0,0 @@
1
- export { resolveOverrides } from './chunk-4LXCYXR5.mjs';