@workleap/tsup-configs 1.0.1 → 2.0.0

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,5 +1,11 @@
1
1
  # @workleap/tsup-configs
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
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
8
+
3
9
  ## 1.0.1
4
10
 
5
11
  ### Patch Changes
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
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
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
28
28
  ```
29
29
 
30
30
  ## Usage
@@ -42,6 +42,28 @@ 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
+ import { defineDevConfig, DefaultDevOptions } from "@workleap/tsup-configs";
61
+
62
+ export default defineDevConfig({
63
+ format: ["cjs", ...DefaultDevOptions.format]
64
+ });
65
+ ```
66
+
45
67
  3. Open the `tsup.build.ts` file and add the following code:
46
68
 
47
69
  ```ts
@@ -51,6 +73,28 @@ import { defineBuildConfig } from "@workleap/tsup-configs";
51
73
  export default defineBuildConfig();
52
74
  ```
53
75
 
76
+ You can override any existing options:
77
+
78
+ ```ts
79
+ // tsup.build.ts
80
+ import { defineBuildConfig } from "@workleap/tsup-configs";
81
+
82
+ export default defineBuildConfig({
83
+ clean: true
84
+ });
85
+ ```
86
+
87
+ 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:
88
+
89
+ ```ts
90
+ // tsup.build.ts
91
+ import { defineBuildConfig, DefaultBuildOptions } from "@workleap/tsup-configs";
92
+
93
+ export default defineBuildConfig({
94
+ format: ["cjs", ...DefaultBuildOptions.format]
95
+ });
96
+ ```
97
+
54
98
  4. In your package.json file, add the following scripts:
55
99
 
56
100
  ```json
@@ -76,6 +120,14 @@ export default defineBuildConfig({
76
120
 
77
121
  [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
122
 
123
+ ## Maintainers notes
124
+
125
+ ### CJS support
126
+
127
+ 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.
128
+
129
+ Once all our projects use ESM, CJS support can be removed.
130
+
79
131
  ## License
80
132
 
81
133
  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.
package/dist/build.d.ts CHANGED
@@ -1,6 +1,16 @@
1
- import * as tsup from 'tsup';
2
- import { DefineConfigOptions } from './mergeConfigs.js';
1
+ import { Options } from 'tsup';
2
+ import { DefineConfigOptions } from './defineConfig.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
+ declare const DefaultBuildOptions: {
5
+ clean: true;
6
+ dts: true;
7
+ treeshake: true;
8
+ entry: string[];
9
+ outDir: string;
10
+ format: string;
11
+ target: "esnext";
12
+ platform: "browser";
13
+ };
14
+ declare function defineBuildConfig(options?: DefineConfigOptions): Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
5
15
 
6
- export { defineBuildConfig };
16
+ export { DefaultBuildOptions, defineBuildConfig };
package/dist/build.js CHANGED
@@ -1,48 +1,48 @@
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);
3
+ var tsup = require('tsup');
4
+
5
+ // src/defineConfig.ts
6
+ function defineConfig(baseOptions, userOptions) {
7
+ if (!userOptions || Array.isArray(userOptions) && userOptions.length === 0) {
8
+ return tsup.defineConfig(baseOptions);
9
+ }
10
+ if (typeof userOptions === "function") {
11
+ return tsup.defineConfig((...args) => ({
12
+ ...baseOptions,
13
+ ...userOptions(...args)
14
+ }));
7
15
  }
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) => {
16
+ if (Array.isArray(userOptions)) {
17
+ return tsup.defineConfig(
18
+ userOptions.map((configItem) => {
18
19
  return {
19
- ...baseConfig,
20
+ ...baseOptions,
20
21
  ...configItem
21
22
  };
22
23
  })
23
24
  );
24
- } else {
25
- return defineConfig({
26
- ...baseConfig,
27
- ...config
28
- });
29
25
  }
26
+ return tsup.defineConfig({
27
+ ...baseOptions,
28
+ ...userOptions
29
+ });
30
30
  }
31
31
 
32
32
  // src/build.ts
33
- function defineBuildConfig(config) {
34
- return mergeConfigs(config, {
35
- clean: true,
36
- dts: true,
37
- minify: true,
38
- splitting: false,
39
- treeshake: true,
40
- entry: ["./src"],
41
- outDir: "./dist",
42
- format: ["esm"],
43
- target: "esnext",
44
- platform: "browser"
45
- });
33
+ var DefaultBuildOptions = {
34
+ clean: true,
35
+ dts: true,
36
+ treeshake: true,
37
+ entry: ["./src"],
38
+ outDir: "./dist",
39
+ format: "esm",
40
+ target: "esnext",
41
+ platform: "browser"
42
+ };
43
+ function defineBuildConfig(options) {
44
+ return defineConfig(DefaultBuildOptions, options);
46
45
  }
47
46
 
48
- export { defineBuildConfig };
47
+ exports.DefaultBuildOptions = DefaultBuildOptions;
48
+ exports.defineBuildConfig = defineBuildConfig;
package/dist/build.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export { DefaultBuildOptions, defineBuildConfig } from './chunk-AJHZ7CZ5.mjs';
2
+ import './chunk-OUAGRIOH.mjs';
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from './chunk-OUAGRIOH.mjs';
2
+
3
+ // src/build.ts
4
+ var DefaultBuildOptions = {
5
+ clean: true,
6
+ dts: true,
7
+ treeshake: true,
8
+ entry: ["./src"],
9
+ outDir: "./dist",
10
+ format: "esm",
11
+ target: "esnext",
12
+ platform: "browser"
13
+ };
14
+ function defineBuildConfig(options) {
15
+ return defineConfig(DefaultBuildOptions, options);
16
+ }
17
+
18
+ export { DefaultBuildOptions, defineBuildConfig };
@@ -0,0 +1,30 @@
1
+ import { defineConfig as defineConfig$1 } from 'tsup';
2
+
3
+ // src/defineConfig.ts
4
+ function defineConfig(baseOptions, userOptions) {
5
+ if (!userOptions || Array.isArray(userOptions) && userOptions.length === 0) {
6
+ return defineConfig$1(baseOptions);
7
+ }
8
+ if (typeof userOptions === "function") {
9
+ return defineConfig$1((...args) => ({
10
+ ...baseOptions,
11
+ ...userOptions(...args)
12
+ }));
13
+ }
14
+ if (Array.isArray(userOptions)) {
15
+ return defineConfig$1(
16
+ userOptions.map((configItem) => {
17
+ return {
18
+ ...baseOptions,
19
+ ...configItem
20
+ };
21
+ })
22
+ );
23
+ }
24
+ return defineConfig$1({
25
+ ...baseOptions,
26
+ ...userOptions
27
+ });
28
+ }
29
+
30
+ export { defineConfig };
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from './chunk-OUAGRIOH.mjs';
2
+
3
+ // src/dev.ts
4
+ var DefaultDevOptions = {
5
+ dts: true,
6
+ watch: true,
7
+ entry: ["./src"],
8
+ outDir: "./dist",
9
+ format: "esm",
10
+ target: "esnext",
11
+ platform: "browser",
12
+ sourcemap: "inline"
13
+ };
14
+ function defineDevConfig(options) {
15
+ return defineConfig(DefaultDevOptions, options);
16
+ }
17
+
18
+ export { DefaultDevOptions, defineDevConfig };
@@ -0,0 +1,6 @@
1
+ import { defineConfig as defineConfig$1, Options } from 'tsup';
2
+
3
+ type DefineConfigOptions = Parameters<typeof defineConfig$1>[0];
4
+ declare function defineConfig(baseOptions: Options, userOptions?: DefineConfigOptions): ReturnType<typeof defineConfig$1>;
5
+
6
+ export { DefineConfigOptions, defineConfig };
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var tsup = require('tsup');
4
+
5
+ // src/defineConfig.ts
6
+ function defineConfig(baseOptions, userOptions) {
7
+ if (!userOptions || Array.isArray(userOptions) && userOptions.length === 0) {
8
+ return tsup.defineConfig(baseOptions);
9
+ }
10
+ if (typeof userOptions === "function") {
11
+ return tsup.defineConfig((...args) => ({
12
+ ...baseOptions,
13
+ ...userOptions(...args)
14
+ }));
15
+ }
16
+ if (Array.isArray(userOptions)) {
17
+ return tsup.defineConfig(
18
+ userOptions.map((configItem) => {
19
+ return {
20
+ ...baseOptions,
21
+ ...configItem
22
+ };
23
+ })
24
+ );
25
+ }
26
+ return tsup.defineConfig({
27
+ ...baseOptions,
28
+ ...userOptions
29
+ });
30
+ }
31
+
32
+ exports.defineConfig = defineConfig;
@@ -0,0 +1 @@
1
+ export { defineConfig } from './chunk-OUAGRIOH.mjs';
package/dist/dev.d.ts CHANGED
@@ -1,6 +1,16 @@
1
- import * as tsup from 'tsup';
2
- import { DefineConfigOptions } from './mergeConfigs.js';
1
+ import { Options } from 'tsup';
2
+ import { DefineConfigOptions } from './defineConfig.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
+ declare const DefaultDevOptions: {
5
+ dts: true;
6
+ watch: true;
7
+ entry: string[];
8
+ outDir: string;
9
+ format: string;
10
+ target: "esnext";
11
+ platform: "browser";
12
+ sourcemap: "inline";
13
+ };
14
+ declare function defineDevConfig(options?: DefineConfigOptions): Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
5
15
 
6
- export { defineDevConfig };
16
+ export { DefaultDevOptions, defineDevConfig };
package/dist/dev.js CHANGED
@@ -1,47 +1,48 @@
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);
3
+ var tsup = require('tsup');
4
+
5
+ // src/defineConfig.ts
6
+ function defineConfig(baseOptions, userOptions) {
7
+ if (!userOptions || Array.isArray(userOptions) && userOptions.length === 0) {
8
+ return tsup.defineConfig(baseOptions);
9
+ }
10
+ if (typeof userOptions === "function") {
11
+ return tsup.defineConfig((...args) => ({
12
+ ...baseOptions,
13
+ ...userOptions(...args)
14
+ }));
7
15
  }
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) => {
16
+ if (Array.isArray(userOptions)) {
17
+ return tsup.defineConfig(
18
+ userOptions.map((configItem) => {
18
19
  return {
19
- ...baseConfig,
20
+ ...baseOptions,
20
21
  ...configItem
21
22
  };
22
23
  })
23
24
  );
24
- } else {
25
- return defineConfig({
26
- ...baseConfig,
27
- ...config
28
- });
29
25
  }
26
+ return tsup.defineConfig({
27
+ ...baseOptions,
28
+ ...userOptions
29
+ });
30
30
  }
31
31
 
32
32
  // src/dev.ts
33
- function defineDevConfig(config) {
34
- return mergeConfigs(config, {
35
- dts: true,
36
- splitting: false,
37
- watch: true,
38
- entry: ["./src"],
39
- outDir: "./dist",
40
- format: ["esm"],
41
- target: "esnext",
42
- platform: "browser",
43
- sourcemap: "inline"
44
- });
33
+ var DefaultDevOptions = {
34
+ dts: true,
35
+ watch: true,
36
+ entry: ["./src"],
37
+ outDir: "./dist",
38
+ format: "esm",
39
+ target: "esnext",
40
+ platform: "browser",
41
+ sourcemap: "inline"
42
+ };
43
+ function defineDevConfig(options) {
44
+ return defineConfig(DefaultDevOptions, options);
45
45
  }
46
46
 
47
- export { defineDevConfig };
47
+ exports.DefaultDevOptions = DefaultDevOptions;
48
+ exports.defineDevConfig = defineDevConfig;
package/dist/dev.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export { DefaultDevOptions, defineDevConfig } from './chunk-TG5YPRC3.mjs';
2
+ import './chunk-OUAGRIOH.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 { DefaultBuildOptions, defineBuildConfig } from './build.js';
2
+ export { DefineConfigOptions } from './defineConfig.js';
3
+ export { DefaultDevOptions, defineDevConfig } from './dev.js';
4
4
  import 'tsup';
package/dist/index.js CHANGED
@@ -1,63 +1,65 @@
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);
3
+ var tsup = require('tsup');
4
+
5
+ // src/defineConfig.ts
6
+ function defineConfig(baseOptions, userOptions) {
7
+ if (!userOptions || Array.isArray(userOptions) && userOptions.length === 0) {
8
+ return tsup.defineConfig(baseOptions);
9
+ }
10
+ if (typeof userOptions === "function") {
11
+ return tsup.defineConfig((...args) => ({
12
+ ...baseOptions,
13
+ ...userOptions(...args)
14
+ }));
7
15
  }
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) => {
16
+ if (Array.isArray(userOptions)) {
17
+ return tsup.defineConfig(
18
+ userOptions.map((configItem) => {
18
19
  return {
19
- ...baseConfig,
20
+ ...baseOptions,
20
21
  ...configItem
21
22
  };
22
23
  })
23
24
  );
24
- } else {
25
- return defineConfig({
26
- ...baseConfig,
27
- ...config
28
- });
29
25
  }
26
+ return tsup.defineConfig({
27
+ ...baseOptions,
28
+ ...userOptions
29
+ });
30
30
  }
31
31
 
32
32
  // src/build.ts
33
- function defineBuildConfig(config) {
34
- return mergeConfigs(config, {
35
- clean: true,
36
- dts: true,
37
- minify: true,
38
- splitting: false,
39
- treeshake: true,
40
- entry: ["./src"],
41
- outDir: "./dist",
42
- format: ["esm"],
43
- target: "esnext",
44
- platform: "browser"
45
- });
33
+ var DefaultBuildOptions = {
34
+ clean: true,
35
+ dts: true,
36
+ treeshake: true,
37
+ entry: ["./src"],
38
+ outDir: "./dist",
39
+ format: "esm",
40
+ target: "esnext",
41
+ platform: "browser"
42
+ };
43
+ function defineBuildConfig(options) {
44
+ return defineConfig(DefaultBuildOptions, options);
46
45
  }
47
46
 
48
47
  // src/dev.ts
49
- function defineDevConfig(config) {
50
- return mergeConfigs(config, {
51
- dts: true,
52
- splitting: false,
53
- watch: true,
54
- entry: ["./src"],
55
- outDir: "./dist",
56
- format: ["esm"],
57
- target: "esnext",
58
- platform: "browser",
59
- sourcemap: "inline"
60
- });
48
+ var DefaultDevOptions = {
49
+ dts: true,
50
+ watch: true,
51
+ entry: ["./src"],
52
+ outDir: "./dist",
53
+ format: "esm",
54
+ target: "esnext",
55
+ platform: "browser",
56
+ sourcemap: "inline"
57
+ };
58
+ function defineDevConfig(options) {
59
+ return defineConfig(DefaultDevOptions, options);
61
60
  }
62
61
 
63
- export { defineBuildConfig, defineDevConfig };
62
+ exports.DefaultBuildOptions = DefaultBuildOptions;
63
+ exports.DefaultDevOptions = DefaultDevOptions;
64
+ exports.defineBuildConfig = defineBuildConfig;
65
+ exports.defineDevConfig = defineDevConfig;
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ export { DefaultBuildOptions, defineBuildConfig } from './chunk-AJHZ7CZ5.mjs';
2
+ export { DefaultDevOptions, defineDevConfig } from './chunk-TG5YPRC3.mjs';
3
+ import './chunk-OUAGRIOH.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.0",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "workleap",
@@ -14,10 +14,10 @@
14
14
  "url": "git+https://github.com/workleap/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",
19
+ "require": "./dist/index.js",
20
+ "import": "./dist/index.mjs",
21
21
  "types": "./dist/index.d.ts"
22
22
  }
23
23
  },
@@ -27,10 +27,17 @@
27
27
  "README.md"
28
28
  ],
29
29
  "devDependencies": {
30
+ "@swc/core": "1.3.62",
31
+ "@swc/helpers": "0.5.1",
32
+ "@swc/jest": "0.2.26",
33
+ "@types/jest": "29.5.2",
34
+ "jest": "29.5.0",
35
+ "ts-node": "10.9.1",
30
36
  "tsup": "6.7.0",
31
37
  "typescript": "5.0.4",
32
- "@workleap/eslint-plugin": "1.8.1",
33
- "@workleap/typescript-configs": "2.3.1"
38
+ "@workleap/eslint-plugin": "1.8.2",
39
+ "@workleap/swc-configs": "1.0.0",
40
+ "@workleap/typescript-configs": "2.3.2"
34
41
  },
35
42
  "peerDependencies": {
36
43
  "tsup": "*"
@@ -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 };