@workleap/tsup-configs 1.0.0 → 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,17 @@
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
+
9
+ ## 1.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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
14
+
3
15
  ## 1.0.0
4
16
 
5
17
  ### Major Changes
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # `@workleap/tsup-configs`
1
+ # @workleap/tsup-configs
2
+
2
3
  Workleap's recommended [tsup](https://tsup.egoist.dev/) configs.
3
4
 
4
5
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](../../LICENSE)
@@ -6,11 +7,24 @@ Workleap's recommended [tsup](https://tsup.egoist.dev/) configs.
6
7
 
7
8
  ## Installation
8
9
 
9
- Install the package.
10
+ Install the following packages:
10
11
 
11
12
  **With pnpm**
13
+
14
+ ```shell
15
+ pnpm add -D @workleap/tsup-configs tsup
16
+ ```
17
+
18
+ **With yarn**
19
+
12
20
  ```shell
13
- pnpm add -D @workleap/tsup-configs
21
+ yarn add -D @workleap/tsup-configs tsup
22
+ ```
23
+
24
+ **With npm**
25
+
26
+ ```shell
27
+ npm install -D @workleap/tsup-configs tsup
14
28
  ```
15
29
 
16
30
  ## Usage
@@ -23,20 +37,64 @@ To build your React or TypeScript library project, follow these steps:
23
37
 
24
38
  ```ts
25
39
  // tsup.dev.ts
26
- import { defineDevConfig } from "tsup";
40
+ import { defineDevConfig } from "@workleap/tsup-configs";
27
41
 
28
42
  export default defineDevConfig();
29
43
  ```
30
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
+
31
67
  3. Open the `tsup.build.ts` file and add the following code:
32
68
 
33
69
  ```ts
34
70
  // tsup.build.ts
35
- import { defineBuildConfig } from "tsup";
71
+ import { defineBuildConfig } from "@workleap/tsup-configs";
36
72
 
37
73
  export default defineBuildConfig();
38
74
  ```
39
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
+
40
98
  4. In your package.json file, add the following scripts:
41
99
 
42
100
  ```json
@@ -47,11 +105,12 @@ export default defineBuildConfig();
47
105
  Now you can use the `dev` script to run tsup in watch mode and the `build` script to build your library.
48
106
 
49
107
  ## Customization
108
+
50
109
  If you want to use additional tsup options or override the default ones, you can pass a custom tsup config to the functions exported by this packages:
51
110
 
52
111
  ```ts
53
112
  // tsup.config.ts
54
- import { defineBuildConfig } from "tsup";
113
+ import { defineBuildConfig } from "@workleap/tsup-configs";
55
114
 
56
115
  export default defineBuildConfig({
57
116
  entry: ["lib/index.ts"],
@@ -61,6 +120,14 @@ export default defineBuildConfig({
61
120
 
62
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/
63
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
+
64
131
  ## License
65
132
 
66
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,2 +1,48 @@
1
- export { a as defineBuildConfig } from './chunk-VN7SD7ZN.js';
2
- import './chunk-KJNVYY35.js';
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
+ // src/build.ts
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);
45
+ }
46
+
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,2 +1,48 @@
1
- export { a as defineDevConfig } from './chunk-Q2XGPH6E.js';
2
- import './chunk-KJNVYY35.js';
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
+ // src/dev.ts
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
+ }
46
+
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,3 +1,65 @@
1
- export { a as defineBuildConfig } from './chunk-VN7SD7ZN.js';
2
- export { a as defineDevConfig } from './chunk-Q2XGPH6E.js';
3
- import './chunk-KJNVYY35.js';
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
+ // src/build.ts
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);
45
+ }
46
+
47
+ // src/dev.ts
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);
60
+ }
61
+
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,10 +2,8 @@
2
2
  "name": "@workleap/tsup-configs",
3
3
  "author": "Workleap",
4
4
  "description": "Workleap's recommended tsup configs.",
5
- "version": "1.0.0",
5
+ "version": "2.0.0",
6
6
  "license": "Apache-2.0",
7
- "type": "module",
8
- "sideEffects": false,
9
7
  "keywords": [
10
8
  "workleap",
11
9
  "tsup",
@@ -16,16 +14,30 @@
16
14
  "url": "git+https://github.com/workleap/wl-web-configs.git",
17
15
  "directory": "packages/tsup-configs"
18
16
  },
19
- "exports": "./dist/index.js",
20
- "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "require": "./dist/index.js",
20
+ "import": "./dist/index.mjs",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
21
24
  "files": [
22
25
  "dist",
23
26
  "CHANGELOG.md",
24
27
  "README.md"
25
28
  ],
26
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",
27
36
  "tsup": "6.7.0",
28
- "@workleap/typescript-configs": "2.3.0"
37
+ "typescript": "5.0.4",
38
+ "@workleap/eslint-plugin": "1.8.2",
39
+ "@workleap/swc-configs": "1.0.0",
40
+ "@workleap/typescript-configs": "2.3.2"
29
41
  },
30
42
  "peerDependencies": {
31
43
  "tsup": "*"
@@ -1,5 +0,0 @@
1
- import { defineConfig } from 'tsup';
2
-
3
- function p(e,r){return e===void 0||Array.isArray(e)&&e.length===0?defineConfig(r):typeof e=="function"?defineConfig(n=>({...r,...e(n)})):Array.isArray(e)?defineConfig(e.map(n=>({...r,...n}))):defineConfig({...r,...e})}
4
-
5
- export { p as a };
@@ -1,5 +0,0 @@
1
- import { a } from './chunk-KJNVYY35.js';
2
-
3
- function n(t){return a(t,{watch:!0,dts:!0,entry:["./src"],outDir:"./dist",format:["esm"],target:"esnext",platform:"browser",sourcemap:"inline"})}
4
-
5
- export { n as a };
@@ -1,5 +0,0 @@
1
- import { a } from './chunk-KJNVYY35.js';
2
-
3
- function i(t){return a(t,{clean:!0,treeshake:!0,minify:!0,dts:!0,entry:["./src"],outDir:"./dist",format:["esm"],target:"esnext",platform:"browser"})}
4
-
5
- export { i as a };
@@ -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 +0,0 @@
1
- export { a as mergeConfigs } from './chunk-KJNVYY35.js';