@workleap/tsup-configs 1.0.1 → 2.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,13 +1,25 @@
1
1
  # @workleap/tsup-configs
2
2
 
3
+ ## 2.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
+
9
+ ## 2.0.0
10
+
11
+ ### Major Changes
12
+
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
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  ### Patch Changes
6
18
 
7
- - [#74](https://github.com/workleap/wl-web-configs/pull/74) [`43c9eb1`](https://github.com/workleap/wl-web-configs/commit/43c9eb11e61896855666c44beb0e711c82a560a3) Thanks [@alexasselin008](https://github.com/alexasselin008)! - Updated installation documentation
19
+ - [#74](https://github.com/gsoft-inc/wl-web-configs/pull/74) [`43c9eb1`](https://github.com/gsoft-inc/wl-web-configs/commit/43c9eb11e61896855666c44beb0e711c82a560a3) Thanks [@alexasselin008](https://github.com/alexasselin008)! - Updated installation documentation
8
20
 
9
21
  ## 1.0.0
10
22
 
11
23
  ### Major Changes
12
24
 
13
- - [#55](https://github.com/workleap/wl-web-configs/pull/55) [`228dc8c`](https://github.com/workleap/wl-web-configs/commit/228dc8cf3a0b3bc82e7c5380c876284583158599) Thanks [@alexasselin008](https://github.com/alexasselin008)! - Initial release
25
+ - [#55](https://github.com/gsoft-inc/wl-web-configs/pull/55) [`228dc8c`](https://github.com/gsoft-inc/wl-web-configs/commit/228dc8cf3a0b3bc82e7c5380c876284583158599) Thanks [@alexasselin008](https://github.com/alexasselin008)! - Initial release
package/README.md CHANGED
@@ -7,24 +7,24 @@ Workleap's recommended [tsup](https://tsup.egoist.dev/) configs.
7
7
 
8
8
  ## Installation
9
9
 
10
- Install the package.
10
+ Install the following packages:
11
11
 
12
12
  **With pnpm**
13
13
 
14
14
  ```shell
15
- pnpm add -D @workleap/tsup-configs
15
+ pnpm add -D @workleap/tsup-configs tsup typescript
16
16
  ```
17
17
 
18
18
  **With yarn**
19
19
 
20
20
  ```shell
21
- yarn add -D @workleap/tsup-configs
21
+ yarn add -D @workleap/tsup-configs tsup typescript
22
22
  ```
23
23
 
24
24
  **With npm**
25
25
 
26
26
  ```shell
27
- npm install -D @workleap/tsup-configs
27
+ npm install -D @workleap/tsup-configs tsup typescript
28
28
  ```
29
29
 
30
30
  ## Usage
@@ -42,15 +42,63 @@ import { defineDevConfig } from "@workleap/tsup-configs";
42
42
  export default defineDevConfig();
43
43
  ```
44
44
 
45
+ You can override any existing options:
46
+
47
+ ```ts
48
+ // tsup.dev.ts
49
+ import { defineDevConfig } from "@workleap/tsup-configs";
50
+
51
+ export default defineDevConfig({
52
+ clean: true
53
+ });
54
+ ```
55
+
56
+ The provided options will be merged with the default options. Given that a provided option match a default option, it will override the default option. If you prefer to extend the default option, you can import the `DefaultDevOptions` object and handle the merging code in your configuration file:
57
+
58
+ ```ts
59
+ // tsup.dev.ts
60
+
61
+ import { defineDevConfig, DefaultDevOptions } from "@workleap/tsup-configs";
62
+
63
+ export default defineDevConfig({
64
+ format: ["cjs", ...DefaultDevOptions.format]
65
+ });
66
+ ```
67
+
45
68
  3. Open the `tsup.build.ts` file and add the following code:
46
69
 
47
70
  ```ts
48
71
  // tsup.build.ts
72
+
49
73
  import { defineBuildConfig } from "@workleap/tsup-configs";
50
74
 
51
75
  export default defineBuildConfig();
52
76
  ```
53
77
 
78
+ You can override any existing options:
79
+
80
+ ```ts
81
+ // tsup.build.ts
82
+
83
+ import { defineBuildConfig } from "@workleap/tsup-configs";
84
+
85
+ export default defineBuildConfig({
86
+ clean: true
87
+ });
88
+ ```
89
+
90
+ The provided options will be merged with the default options. Given that a provided option matches a default option, it will override the default option. If you prefer to extend the default option, you can import the `DefaultBuildOptions` object and handle the merging code in your configuration file:
91
+
92
+ ```ts
93
+ // tsup.build.ts
94
+
95
+ import { defineBuildConfig, DefaultBuildOptions } from "@workleap/tsup-configs";
96
+
97
+ export default defineBuildConfig({
98
+ format: ["cjs", ...DefaultBuildOptions.format]
99
+ });
100
+ ```
101
+
54
102
  4. In your package.json file, add the following scripts:
55
103
 
56
104
  ```json
@@ -66,6 +114,7 @@ If you want to use additional tsup options or override the default ones, you can
66
114
 
67
115
  ```ts
68
116
  // tsup.config.ts
117
+
69
118
  import { defineBuildConfig } from "@workleap/tsup-configs";
70
119
 
71
120
  export default defineBuildConfig({
@@ -76,6 +125,14 @@ export default defineBuildConfig({
76
125
 
77
126
  [Check out all available options here](https://paka.dev/npm/tsup#module-index-export-Options) or the documentation website at https://tsup.egoist.dev/
78
127
 
128
+ ## Maintainers notes
129
+
130
+ ### CJS support
131
+
132
+ 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.
133
+
134
+ Once all our projects use ESM, CJS support can be removed.
135
+
79
136
  ## License
80
137
 
81
138
  Copyright © 2023, GSoft inc. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/gsoft-inc/gsoft-license/blob/master/LICENSE.
@@ -0,0 +1,9 @@
1
+ import { Options } from 'tsup';
2
+
3
+ interface TsupConfigTransformerContext {
4
+ environment: "dev" | "build";
5
+ }
6
+ type TsupConfigTransformer = (config: Options, context: TsupConfigTransformerContext) => Options;
7
+ declare function applyTransformers(config: Options, transformers: TsupConfigTransformer[], context: TsupConfigTransformerContext): Options;
8
+
9
+ export { TsupConfigTransformer, TsupConfigTransformerContext, 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,6 +1,9 @@
1
- import * as tsup from 'tsup';
2
- import { DefineConfigOptions } from './mergeConfigs.js';
1
+ import { Options } from 'tsup';
2
+ import { TsupConfigTransformer } from './applyTransformers.js';
3
3
 
4
- declare function defineBuildConfig(config?: DefineConfigOptions): tsup.Options | tsup.Options[] | ((overrideOptions: tsup.Options) => tsup.Options | tsup.Options[] | Promise<tsup.Options | tsup.Options[]>);
4
+ interface DefineBuildConfigOptions extends Options {
5
+ transformers?: TsupConfigTransformer[];
6
+ }
7
+ declare function defineBuildConfig(options?: DefineBuildConfigOptions): Options;
5
8
 
6
- export { defineBuildConfig };
9
+ export { DefineBuildConfigOptions, defineBuildConfig };
package/dist/build.js CHANGED
@@ -1,48 +1,31 @@
1
- import { defineConfig } from 'tsup';
1
+ 'use strict';
2
2
 
3
- // src/mergeConfigs.ts
4
- function mergeConfigs(config, baseConfig) {
5
- if (config === void 0 || Array.isArray(config) && config.length === 0) {
6
- return defineConfig(baseConfig);
7
- }
8
- if (typeof config === "function") {
9
- return defineConfig((cliFlags) => {
10
- return {
11
- ...baseConfig,
12
- ...config(cliFlags)
13
- };
14
- });
15
- } else if (Array.isArray(config)) {
16
- return defineConfig(
17
- config.map((configItem) => {
18
- return {
19
- ...baseConfig,
20
- ...configItem
21
- };
22
- })
23
- );
24
- } else {
25
- return defineConfig({
26
- ...baseConfig,
27
- ...config
28
- });
29
- }
3
+ // src/applyTransformers.ts
4
+ function applyTransformers(config, transformers, context) {
5
+ return transformers.reduce((acc, transformer) => transformer(acc, context), config);
30
6
  }
31
7
 
32
8
  // src/build.ts
33
- function defineBuildConfig(config) {
34
- return mergeConfigs(config, {
9
+ function defineBuildConfig(options = {}) {
10
+ const {
11
+ transformers = [],
12
+ ...rest
13
+ } = options;
14
+ const config = {
35
15
  clean: true,
36
16
  dts: true,
37
- minify: true,
38
- splitting: false,
39
17
  treeshake: true,
40
18
  entry: ["./src"],
41
19
  outDir: "./dist",
42
- format: ["esm"],
20
+ format: "esm",
43
21
  target: "esnext",
44
- platform: "browser"
22
+ platform: "browser",
23
+ ...rest
24
+ };
25
+ const transformedConfig = applyTransformers(config, transformers, {
26
+ environment: "build"
45
27
  });
28
+ return transformedConfig;
46
29
  }
47
30
 
48
- export { defineBuildConfig };
31
+ exports.defineBuildConfig = defineBuildConfig;
package/dist/build.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export { defineBuildConfig } from './chunk-JENCWRR7.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,26 @@
1
+ import { applyTransformers } from './chunk-3UBBOKDF.mjs';
2
+
3
+ // src/dev.ts
4
+ function defineDevConfig(options = {}) {
5
+ const {
6
+ transformers = [],
7
+ ...rest
8
+ } = options;
9
+ const config = {
10
+ dts: true,
11
+ watch: true,
12
+ entry: ["./src"],
13
+ outDir: "./dist",
14
+ format: "esm",
15
+ target: "esnext",
16
+ platform: "browser",
17
+ sourcemap: "inline",
18
+ ...rest
19
+ };
20
+ const transformedConfig = applyTransformers(config, transformers, {
21
+ environment: "dev"
22
+ });
23
+ return transformedConfig;
24
+ }
25
+
26
+ export { defineDevConfig };
@@ -0,0 +1,26 @@
1
+ import { applyTransformers } from './chunk-3UBBOKDF.mjs';
2
+
3
+ // src/build.ts
4
+ function defineBuildConfig(options = {}) {
5
+ const {
6
+ transformers = [],
7
+ ...rest
8
+ } = options;
9
+ const config = {
10
+ clean: true,
11
+ dts: true,
12
+ treeshake: true,
13
+ entry: ["./src"],
14
+ outDir: "./dist",
15
+ format: "esm",
16
+ target: "esnext",
17
+ platform: "browser",
18
+ ...rest
19
+ };
20
+ const transformedConfig = applyTransformers(config, transformers, {
21
+ environment: "build"
22
+ });
23
+ return transformedConfig;
24
+ }
25
+
26
+ export { defineBuildConfig };
package/dist/dev.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import * as tsup from 'tsup';
2
- import { DefineConfigOptions } from './mergeConfigs.js';
1
+ import { Options } from 'tsup';
2
+ import { TsupConfigTransformer } from './applyTransformers.js';
3
3
 
4
- declare function defineDevConfig(config?: DefineConfigOptions): tsup.Options | tsup.Options[] | ((overrideOptions: tsup.Options) => tsup.Options | tsup.Options[] | Promise<tsup.Options | tsup.Options[]>);
4
+ interface DefineDevConfigOptions extends Options {
5
+ transformers?: TsupConfigTransformer[];
6
+ }
7
+ declare function defineDevConfig(options?: DefineDevConfigOptions): Options;
5
8
 
6
- export { defineDevConfig };
9
+ export { DefineDevConfigOptions, defineDevConfig };
package/dist/dev.js CHANGED
@@ -1,47 +1,31 @@
1
- import { defineConfig } from 'tsup';
1
+ 'use strict';
2
2
 
3
- // src/mergeConfigs.ts
4
- function mergeConfigs(config, baseConfig) {
5
- if (config === void 0 || Array.isArray(config) && config.length === 0) {
6
- return defineConfig(baseConfig);
7
- }
8
- if (typeof config === "function") {
9
- return defineConfig((cliFlags) => {
10
- return {
11
- ...baseConfig,
12
- ...config(cliFlags)
13
- };
14
- });
15
- } else if (Array.isArray(config)) {
16
- return defineConfig(
17
- config.map((configItem) => {
18
- return {
19
- ...baseConfig,
20
- ...configItem
21
- };
22
- })
23
- );
24
- } else {
25
- return defineConfig({
26
- ...baseConfig,
27
- ...config
28
- });
29
- }
3
+ // src/applyTransformers.ts
4
+ function applyTransformers(config, transformers, context) {
5
+ return transformers.reduce((acc, transformer) => transformer(acc, context), config);
30
6
  }
31
7
 
32
8
  // src/dev.ts
33
- function defineDevConfig(config) {
34
- return mergeConfigs(config, {
9
+ function defineDevConfig(options = {}) {
10
+ const {
11
+ transformers = [],
12
+ ...rest
13
+ } = options;
14
+ const config = {
35
15
  dts: true,
36
- splitting: false,
37
16
  watch: true,
38
17
  entry: ["./src"],
39
18
  outDir: "./dist",
40
- format: ["esm"],
19
+ format: "esm",
41
20
  target: "esnext",
42
21
  platform: "browser",
43
- sourcemap: "inline"
22
+ sourcemap: "inline",
23
+ ...rest
24
+ };
25
+ const transformedConfig = applyTransformers(config, transformers, {
26
+ environment: "dev"
44
27
  });
28
+ return transformedConfig;
45
29
  }
46
30
 
47
- export { defineDevConfig };
31
+ exports.defineDevConfig = defineDevConfig;
package/dist/dev.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export { defineDevConfig } from './chunk-DQ32U23F.mjs';
2
+ import './chunk-3UBBOKDF.mjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { defineBuildConfig } from './build.js';
2
- export { defineDevConfig } from './dev.js';
3
- export { DefineConfigOptions } from './mergeConfigs.js';
1
+ export { TsupConfigTransformer, TsupConfigTransformerContext } from './applyTransformers.js';
2
+ export { DefineBuildConfigOptions, defineBuildConfig } from './build.js';
3
+ export { DefineDevConfigOptions, defineDevConfig } from './dev.js';
4
4
  import 'tsup';
package/dist/index.js CHANGED
@@ -1,63 +1,55 @@
1
- import { defineConfig } from 'tsup';
1
+ 'use strict';
2
2
 
3
- // src/mergeConfigs.ts
4
- function mergeConfigs(config, baseConfig) {
5
- if (config === void 0 || Array.isArray(config) && config.length === 0) {
6
- return defineConfig(baseConfig);
7
- }
8
- if (typeof config === "function") {
9
- return defineConfig((cliFlags) => {
10
- return {
11
- ...baseConfig,
12
- ...config(cliFlags)
13
- };
14
- });
15
- } else if (Array.isArray(config)) {
16
- return defineConfig(
17
- config.map((configItem) => {
18
- return {
19
- ...baseConfig,
20
- ...configItem
21
- };
22
- })
23
- );
24
- } else {
25
- return defineConfig({
26
- ...baseConfig,
27
- ...config
28
- });
29
- }
3
+ // src/applyTransformers.ts
4
+ function applyTransformers(config, transformers, context) {
5
+ return transformers.reduce((acc, transformer) => transformer(acc, context), config);
30
6
  }
31
7
 
32
8
  // src/build.ts
33
- function defineBuildConfig(config) {
34
- return mergeConfigs(config, {
9
+ function defineBuildConfig(options = {}) {
10
+ const {
11
+ transformers = [],
12
+ ...rest
13
+ } = options;
14
+ const config = {
35
15
  clean: true,
36
16
  dts: true,
37
- minify: true,
38
- splitting: false,
39
17
  treeshake: true,
40
18
  entry: ["./src"],
41
19
  outDir: "./dist",
42
- format: ["esm"],
20
+ format: "esm",
43
21
  target: "esnext",
44
- platform: "browser"
22
+ platform: "browser",
23
+ ...rest
24
+ };
25
+ const transformedConfig = applyTransformers(config, transformers, {
26
+ environment: "build"
45
27
  });
28
+ return transformedConfig;
46
29
  }
47
30
 
48
31
  // src/dev.ts
49
- function defineDevConfig(config) {
50
- return mergeConfigs(config, {
32
+ function defineDevConfig(options = {}) {
33
+ const {
34
+ transformers = [],
35
+ ...rest
36
+ } = options;
37
+ const config = {
51
38
  dts: true,
52
- splitting: false,
53
39
  watch: true,
54
40
  entry: ["./src"],
55
41
  outDir: "./dist",
56
- format: ["esm"],
42
+ format: "esm",
57
43
  target: "esnext",
58
44
  platform: "browser",
59
- sourcemap: "inline"
45
+ sourcemap: "inline",
46
+ ...rest
47
+ };
48
+ const transformedConfig = applyTransformers(config, transformers, {
49
+ environment: "dev"
60
50
  });
51
+ return transformedConfig;
61
52
  }
62
53
 
63
- export { defineBuildConfig, defineDevConfig };
54
+ exports.defineBuildConfig = defineBuildConfig;
55
+ exports.defineDevConfig = defineDevConfig;
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ export { defineBuildConfig } from './chunk-JENCWRR7.mjs';
2
+ export { defineDevConfig } from './chunk-DQ32U23F.mjs';
3
+ import './chunk-3UBBOKDF.mjs';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@workleap/tsup-configs",
3
3
  "author": "Workleap",
4
4
  "description": "Workleap's recommended tsup configs.",
5
- "version": "1.0.1",
5
+ "version": "2.0.1",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "workleap",
@@ -11,14 +11,15 @@
11
11
  ],
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/workleap/wl-web-configs.git",
14
+ "url": "git+https://github.com/gsoft-inc/wl-web-configs.git",
15
15
  "directory": "packages/tsup-configs"
16
16
  },
17
- "type": "module",
18
17
  "exports": {
19
18
  ".": {
20
- "import": "./dist/index.js",
21
- "types": "./dist/index.d.ts"
19
+ "require": "./dist/index.js",
20
+ "import": "./dist/index.mjs",
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.mjs"
22
23
  }
23
24
  },
24
25
  "files": [
@@ -26,14 +27,22 @@
26
27
  "CHANGELOG.md",
27
28
  "README.md"
28
29
  ],
30
+ "peerDependencies": {
31
+ "tsup": "*",
32
+ "typescript": "*"
33
+ },
29
34
  "devDependencies": {
35
+ "@swc/core": "1.3.62",
36
+ "@swc/helpers": "0.5.1",
37
+ "@swc/jest": "0.2.26",
38
+ "@types/jest": "29.5.2",
39
+ "jest": "29.5.0",
40
+ "ts-node": "10.9.1",
30
41
  "tsup": "6.7.0",
31
42
  "typescript": "5.0.4",
32
- "@workleap/eslint-plugin": "1.8.1",
33
- "@workleap/typescript-configs": "2.3.1"
34
- },
35
- "peerDependencies": {
36
- "tsup": "*"
43
+ "@workleap/eslint-plugin": "1.8.3",
44
+ "@workleap/swc-configs": "1.0.1",
45
+ "@workleap/typescript-configs": "2.3.3"
37
46
  },
38
47
  "publishConfig": {
39
48
  "access": "public",
@@ -1,6 +0,0 @@
1
- import { defineConfig, Options } from 'tsup';
2
-
3
- type DefineConfigOptions = Parameters<typeof defineConfig>[0];
4
- declare function mergeConfigs(config: DefineConfigOptions | undefined, baseConfig: Options): ReturnType<typeof defineConfig>;
5
-
6
- export { DefineConfigOptions, mergeConfigs };
@@ -1,32 +0,0 @@
1
- import { defineConfig } from 'tsup';
2
-
3
- // src/mergeConfigs.ts
4
- function mergeConfigs(config, baseConfig) {
5
- if (config === void 0 || Array.isArray(config) && config.length === 0) {
6
- return defineConfig(baseConfig);
7
- }
8
- if (typeof config === "function") {
9
- return defineConfig((cliFlags) => {
10
- return {
11
- ...baseConfig,
12
- ...config(cliFlags)
13
- };
14
- });
15
- } else if (Array.isArray(config)) {
16
- return defineConfig(
17
- config.map((configItem) => {
18
- return {
19
- ...baseConfig,
20
- ...configItem
21
- };
22
- })
23
- );
24
- } else {
25
- return defineConfig({
26
- ...baseConfig,
27
- ...config
28
- });
29
- }
30
- }
31
-
32
- export { mergeConfigs };