@procore/hammer-lib-tsup 0.3.1 → 0.4.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/README.md CHANGED
@@ -42,10 +42,13 @@ This project uses [`yarn`][yarn], and supports the following commands:
42
42
  - `clean`: deletes the output directory and any built files.
43
43
  - `format`: runs [`prettier`][prettier] on the project.
44
44
  - `format:check`: uses [`prettier`][prettier] to validate code format.
45
+ - `lint:code`: uses [`eslint`][eslint] to lint code.
46
+ - `lint:types`: uses [`TypeScript`][typescript] to validate types.
45
47
  - `test`: runs the unit test suite.
46
48
  - `test:ci`: run the unit test suite, reporting coverage.
47
49
 
48
- [define-config]:
50
+ [eslint]: https://eslint.org/
49
51
  [prettier]: https://prettier.io/
50
52
  [tsup]: https://tsup.egoist.dev/
53
+ [typescript]: https://www.typescriptlang.org/
51
54
  [yarn]: https://classic.yarnpkg.com/
package/dist/index.d.mts CHANGED
@@ -1,8 +1,14 @@
1
1
  import * as _procore_hammer_types from '@procore/hammer-types';
2
2
 
3
- declare const build: _procore_hammer_types.LibPluginFunction;
4
- declare const clean: _procore_hammer_types.LibPluginFunction;
5
- declare const inspect: _procore_hammer_types.LibPluginFunction;
6
- declare const start: _procore_hammer_types.LibPluginFunction;
3
+ declare const build: (rootDir: string, config: _procore_hammer_types.HammerConfig, options: {
4
+ analyze: boolean;
5
+ }) => Promise<void>;
6
+ declare const clean: (rootDir: string, config: _procore_hammer_types.HammerConfig) => Promise<void>;
7
+ declare const inspect: (rootDir: string, config: _procore_hammer_types.HammerConfig, options: {
8
+ analyze: boolean;
9
+ }) => Promise<void>;
10
+ declare const start: (rootDir: string, config: _procore_hammer_types.HammerConfig, options: {
11
+ analyze: boolean;
12
+ }) => Promise<void>;
7
13
 
8
14
  export { build, clean, inspect, start };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import * as _procore_hammer_types from '@procore/hammer-types';
2
2
 
3
- declare const build: _procore_hammer_types.LibPluginFunction;
4
- declare const clean: _procore_hammer_types.LibPluginFunction;
5
- declare const inspect: _procore_hammer_types.LibPluginFunction;
6
- declare const start: _procore_hammer_types.LibPluginFunction;
3
+ declare const build: (rootDir: string, config: _procore_hammer_types.HammerConfig, options: {
4
+ analyze: boolean;
5
+ }) => Promise<void>;
6
+ declare const clean: (rootDir: string, config: _procore_hammer_types.HammerConfig) => Promise<void>;
7
+ declare const inspect: (rootDir: string, config: _procore_hammer_types.HammerConfig, options: {
8
+ analyze: boolean;
9
+ }) => Promise<void>;
10
+ declare const start: (rootDir: string, config: _procore_hammer_types.HammerConfig, options: {
11
+ analyze: boolean;
12
+ }) => Promise<void>;
7
13
 
8
14
  export { build, clean, inspect, start };
package/dist/index.js CHANGED
@@ -39,6 +39,7 @@ module.exports = __toCommonJS(src_exports);
39
39
  var import_node_process = __toESM(require("process"));
40
40
 
41
41
  // src/base-configs.ts
42
+ var import_esbuild_sass_plugin = require("esbuild-sass-plugin");
42
43
  var baseOptions = {
43
44
  entry: ["src/index.ts"],
44
45
  format: ["cjs", "esm"],
@@ -46,7 +47,13 @@ var baseOptions = {
46
47
  clean: true,
47
48
  loader: {
48
49
  ".svg": "copy"
49
- }
50
+ },
51
+ esbuildPlugins: [
52
+ (0, import_esbuild_sass_plugin.sassPlugin)({
53
+ type: "style",
54
+ transform: (0, import_esbuild_sass_plugin.postcssModules)({})
55
+ })
56
+ ]
50
57
  };
51
58
  var modernOptions = {
52
59
  ...baseOptions,
@@ -78,7 +85,7 @@ async function createBuildOptions(config, options) {
78
85
  return overriddenOptions.map((buildOptions) => ({
79
86
  ...buildOptions,
80
87
  // adds metafile flag for bundle analysis, if defined.
81
- metafile: options.analyze,
88
+ metafile: Boolean(options.analyze),
82
89
  ...options.watch ? { watch: options.watch } : void 0
83
90
  }));
84
91
  }
@@ -97,7 +104,7 @@ function toHighlightedString(input) {
97
104
  }
98
105
 
99
106
  // src/clean-output.ts
100
- var import_node_path = require("path");
107
+ var import_pathe = require("pathe");
101
108
  var import_promises = require("fs/promises");
102
109
  var import_picocolors = __toESM(require("picocolors"));
103
110
  async function cleanOutput(rootDir, buildOptions) {
@@ -106,7 +113,7 @@ async function cleanOutput(rootDir, buildOptions) {
106
113
  if (buildOption.outDir) {
107
114
  process.stdout.write(`Cleaning ${import_picocolors.default.bold(name)} library...
108
115
  `);
109
- await (0, import_promises.rm)((0, import_node_path.resolve)(rootDir, buildOption.outDir), {
116
+ await (0, import_promises.rm)((0, import_pathe.resolve)(rootDir, buildOption.outDir), {
110
117
  recursive: true,
111
118
  force: true
112
119
  });
@@ -140,26 +147,27 @@ async function performBuild(buildOptions) {
140
147
 
141
148
  // src/index.ts
142
149
  var { build, clean, inspect, start } = {
143
- build: async function build2(pluginOptions) {
150
+ build: async function build2(rootDir, config, options) {
151
+ const pluginOptions = { ...options, config };
144
152
  const buildOptions = await createBuildOptions(base_configs_default, pluginOptions);
145
153
  await performBuild(buildOptions);
146
154
  },
147
- clean: async function clean2(options) {
148
- const buildOptions = await createBuildOptions(base_configs_default, options);
149
- await cleanOutput(options.rootDir, buildOptions);
155
+ clean: async function clean2(rootDir, config) {
156
+ const pluginOptions = { config };
157
+ const buildOptions = await createBuildOptions(base_configs_default, pluginOptions);
158
+ await cleanOutput(rootDir, buildOptions);
150
159
  },
151
- inspect: async function inspect2(options) {
152
- const buildOptions = await createBuildOptions(base_configs_default, options);
160
+ inspect: async function inspect2(rootDir, config, options) {
161
+ const pluginOptions = { ...options, config };
162
+ const buildOptions = await createBuildOptions(base_configs_default, pluginOptions);
153
163
  const highlightedConfig = toHighlightedString(buildOptions);
154
164
  import_node_process.default.stdout.write(`
155
165
  ${highlightedConfig}
156
166
  `);
157
167
  },
158
- start: async function start2(pluginOptions) {
159
- const buildOptions = await createBuildOptions(base_configs_default, {
160
- ...pluginOptions,
161
- watch: true
162
- });
168
+ start: async function start2(rootDir, config, options) {
169
+ const pluginOptions = { ...options, config, watch: true };
170
+ const buildOptions = await createBuildOptions(base_configs_default, pluginOptions);
163
171
  await performBuild(buildOptions);
164
172
  }
165
173
  };
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
  import process2 from "process";
3
3
 
4
4
  // src/base-configs.ts
5
+ import { postcssModules, sassPlugin } from "esbuild-sass-plugin";
5
6
  var baseOptions = {
6
7
  entry: ["src/index.ts"],
7
8
  format: ["cjs", "esm"],
@@ -9,7 +10,13 @@ var baseOptions = {
9
10
  clean: true,
10
11
  loader: {
11
12
  ".svg": "copy"
12
- }
13
+ },
14
+ esbuildPlugins: [
15
+ sassPlugin({
16
+ type: "style",
17
+ transform: postcssModules({})
18
+ })
19
+ ]
13
20
  };
14
21
  var modernOptions = {
15
22
  ...baseOptions,
@@ -41,7 +48,7 @@ async function createBuildOptions(config, options) {
41
48
  return overriddenOptions.map((buildOptions) => ({
42
49
  ...buildOptions,
43
50
  // adds metafile flag for bundle analysis, if defined.
44
- metafile: options.analyze,
51
+ metafile: Boolean(options.analyze),
45
52
  ...options.watch ? { watch: options.watch } : void 0
46
53
  }));
47
54
  }
@@ -60,7 +67,7 @@ function toHighlightedString(input) {
60
67
  }
61
68
 
62
69
  // src/clean-output.ts
63
- import { resolve } from "path";
70
+ import { resolve } from "pathe";
64
71
  import { rm } from "fs/promises";
65
72
  import c from "picocolors";
66
73
  async function cleanOutput(rootDir, buildOptions) {
@@ -103,26 +110,27 @@ async function performBuild(buildOptions) {
103
110
 
104
111
  // src/index.ts
105
112
  var { build, clean, inspect, start } = {
106
- build: async function build2(pluginOptions) {
113
+ build: async function build2(rootDir, config, options) {
114
+ const pluginOptions = { ...options, config };
107
115
  const buildOptions = await createBuildOptions(base_configs_default, pluginOptions);
108
116
  await performBuild(buildOptions);
109
117
  },
110
- clean: async function clean2(options) {
111
- const buildOptions = await createBuildOptions(base_configs_default, options);
112
- await cleanOutput(options.rootDir, buildOptions);
118
+ clean: async function clean2(rootDir, config) {
119
+ const pluginOptions = { config };
120
+ const buildOptions = await createBuildOptions(base_configs_default, pluginOptions);
121
+ await cleanOutput(rootDir, buildOptions);
113
122
  },
114
- inspect: async function inspect2(options) {
115
- const buildOptions = await createBuildOptions(base_configs_default, options);
123
+ inspect: async function inspect2(rootDir, config, options) {
124
+ const pluginOptions = { ...options, config };
125
+ const buildOptions = await createBuildOptions(base_configs_default, pluginOptions);
116
126
  const highlightedConfig = toHighlightedString(buildOptions);
117
127
  process2.stdout.write(`
118
128
  ${highlightedConfig}
119
129
  `);
120
130
  },
121
- start: async function start2(pluginOptions) {
122
- const buildOptions = await createBuildOptions(base_configs_default, {
123
- ...pluginOptions,
124
- watch: true
125
- });
131
+ start: async function start2(rootDir, config, options) {
132
+ const pluginOptions = { ...options, config, watch: true };
133
+ const buildOptions = await createBuildOptions(base_configs_default, pluginOptions);
126
134
  await performBuild(buildOptions);
127
135
  }
128
136
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/hammer-lib-tsup",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Hammer library builder, tsup-style",
5
5
  "author": "Procore Technologies, Inc",
6
6
  "homepage": "https://github.com/procore/hammer/packages/lib-tsup",
@@ -35,21 +35,24 @@
35
35
  "exec": "exec",
36
36
  "format": "prettier --ignore-unknown --write --cache .",
37
37
  "format:check": "prettier --ignore-unknown --check --cache .",
38
- "lint": "eslint . --cache",
38
+ "lint:code": "eslint . --cache",
39
+ "lint:types": "tsc --noEmit",
39
40
  "prepack": "tsup",
40
41
  "test": "vitest run",
41
- "test:ci": "vitest run --coverage"
42
+ "test:ci": "vitest run --coverage",
43
+ "test:watch": "vitest"
42
44
  },
43
45
  "dependencies": {
44
- "@procore/hammer-types": "^0.2.0",
46
+ "@procore/hammer-types": "^0.3.0",
45
47
  "cli-highlight": "^2.1.11",
48
+ "pathe": "^1.1.2",
49
+ "esbuild-sass-plugin": "^3.2.0",
46
50
  "picocolors": "^1.0.0",
47
51
  "tsup": "^8.0.2"
48
52
  },
49
53
  "devDependencies": {
50
54
  "@procore/prettier-config": "^1.0.0",
51
55
  "@types/node": "^20.12.7",
52
- "@types/semver": "^7.5.8",
53
56
  "@typescript-eslint/eslint-plugin": "^7.7.1",
54
57
  "@typescript-eslint/parser": "^7.7.1",
55
58
  "@vitest/coverage-v8": "^1.5.1",