@sanity/pkg-utils 3.0.0 → 3.1.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/_chunks/{build-tEW4TKwN.cjs → build-ttL1gCQE.cjs} +2 -2
- package/dist/_chunks/{build-tEW4TKwN.cjs.map → build-ttL1gCQE.cjs.map} +1 -1
- package/dist/_chunks/{buildAction-Jeq4BaXO.cjs → buildAction-2FuCIzEr.cjs} +2 -2
- package/dist/_chunks/{buildAction-Jeq4BaXO.cjs.map → buildAction-2FuCIzEr.cjs.map} +1 -1
- package/dist/_chunks/{index-iuLMZGMV.cjs → index-jC5AhNHb.cjs} +3 -6
- package/dist/_chunks/{index-iuLMZGMV.cjs.map → index-jC5AhNHb.cjs.map} +1 -1
- package/dist/_chunks/{watch-dvtM5oqQ.cjs → watch-UrB-haEA.cjs} +2 -2
- package/dist/_chunks/{watch-dvtM5oqQ.cjs.map → watch-UrB-haEA.cjs.map} +1 -1
- package/dist/_chunks/{watchAction-KRiiioTQ.cjs → watchAction-1U3Gh9UD.cjs} +2 -2
- package/dist/_chunks/{watchAction-KRiiioTQ.cjs.map → watchAction-1U3Gh9UD.cjs.map} +1 -1
- package/dist/cli.cjs +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +0 -5
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/package.json +43 -70
- package/src/node/core/config/types.ts +0 -5
- package/src/node/tasks/rollup/resolveRollupConfig.ts +7 -10
- package/src/node/tasks/rollup/rollupTask.ts +0 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -46,25 +46,6 @@
|
|
|
46
46
|
"!dist/stats.html",
|
|
47
47
|
"src"
|
|
48
48
|
],
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "run-s clean build:pkg check:pkg",
|
|
51
|
-
"build:pkg": "node --loader esbuild-register/loader -r esbuild-register scripts/build",
|
|
52
|
-
"check:pkg": "node --loader esbuild-register/loader -r esbuild-register scripts/check",
|
|
53
|
-
"check:types": "tsc --build",
|
|
54
|
-
"clean": "rimraf dist",
|
|
55
|
-
"commit": "cz",
|
|
56
|
-
"extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
|
|
57
|
-
"format": "prettier --write --cache --ignore-unknown . && eslint . --ext .cjs,.js,.ts,.tsx --fix --quiet",
|
|
58
|
-
"lint": "eslint . --ext .cjs,.js,.ts,.tsx",
|
|
59
|
-
"playground:build": "pnpm --filter './playground/**' build",
|
|
60
|
-
"playground:clean": "pnpm --filter './playground/**' --silent clean",
|
|
61
|
-
"prepublishOnly": "pnpm run build",
|
|
62
|
-
"release": "semantic-release",
|
|
63
|
-
"test": "run-s playground:clean test:clean vitest:run",
|
|
64
|
-
"test:clean": "rimraf test/env/__tmp__",
|
|
65
|
-
"vitest:run": "vitest run",
|
|
66
|
-
"watch": "node --loader esbuild-register/loader -r esbuild-register scripts/watch"
|
|
67
|
-
},
|
|
68
49
|
"commitlint": {
|
|
69
50
|
"extends": [
|
|
70
51
|
"@commitlint/config-conventional"
|
|
@@ -105,40 +86,24 @@
|
|
|
105
86
|
}
|
|
106
87
|
]
|
|
107
88
|
},
|
|
108
|
-
"release": {
|
|
109
|
-
"branches": [
|
|
110
|
-
"+([0-9])?(.{+([0-9]),x}).x",
|
|
111
|
-
"main",
|
|
112
|
-
"next",
|
|
113
|
-
{
|
|
114
|
-
"name": "beta",
|
|
115
|
-
"prerelease": true
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"name": "alpha",
|
|
119
|
-
"prerelease": true
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
"extends": "@sanity/semantic-release-preset"
|
|
123
|
-
},
|
|
124
89
|
"dependencies": {
|
|
125
|
-
"@babel/core": "^7.23.
|
|
126
|
-
"@babel/preset-env": "^7.
|
|
90
|
+
"@babel/core": "^7.23.2",
|
|
91
|
+
"@babel/preset-env": "^7.23.2",
|
|
127
92
|
"@babel/types": "^7.23.0",
|
|
128
93
|
"@microsoft/api-extractor": "^7.38.0",
|
|
129
94
|
"@microsoft/tsdoc-config": "^0.16.2",
|
|
130
95
|
"@rollup/plugin-alias": "^5.0.1",
|
|
131
96
|
"@rollup/plugin-babel": "^6.0.4",
|
|
132
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
97
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
133
98
|
"@rollup/plugin-json": "^6.0.1",
|
|
134
99
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
135
|
-
"@rollup/plugin-replace": "^5.0.
|
|
100
|
+
"@rollup/plugin-replace": "^5.0.4",
|
|
136
101
|
"@rollup/plugin-terser": "^0.4.4",
|
|
137
102
|
"browserslist": "^4.22.1",
|
|
138
103
|
"cac": "^6.7.14",
|
|
139
104
|
"chalk": "^4.1.2",
|
|
140
105
|
"chokidar": "^3.5.3",
|
|
141
|
-
"esbuild": "^0.19.
|
|
106
|
+
"esbuild": "^0.19.5",
|
|
142
107
|
"esbuild-register": "^3.5.0",
|
|
143
108
|
"find-config": "^1.0.0",
|
|
144
109
|
"get-latest-version": "^5.1.0",
|
|
@@ -154,65 +119,73 @@
|
|
|
154
119
|
"pretty-bytes": "^5.6.0",
|
|
155
120
|
"prompts": "^2.4.2",
|
|
156
121
|
"rimraf": "^4.4.1",
|
|
157
|
-
"rollup": "^4.
|
|
122
|
+
"rollup": "^4.1.4",
|
|
158
123
|
"rollup-plugin-esbuild": "^6.1.0",
|
|
159
|
-
"rollup-plugin-preserve-directives": "^0.2.0",
|
|
160
124
|
"rxjs": "^7.8.1",
|
|
161
125
|
"treeify": "^1.1.0",
|
|
162
126
|
"uuid": "^9.0.1",
|
|
163
127
|
"zod": "^3.22.4"
|
|
164
128
|
},
|
|
165
129
|
"devDependencies": {
|
|
166
|
-
"@commitlint/cli": "^17.
|
|
167
|
-
"@commitlint/config-conventional": "^17.
|
|
168
|
-
"@
|
|
169
|
-
"@
|
|
170
|
-
"@types/
|
|
171
|
-
"@types/
|
|
172
|
-
"@types/
|
|
173
|
-
"@types/git-
|
|
174
|
-
"@types/
|
|
175
|
-
"@types/parse-git-config": "^3.0.2",
|
|
176
|
-
"@types/prompts": "^2.4.5",
|
|
130
|
+
"@commitlint/cli": "^17.8.0",
|
|
131
|
+
"@commitlint/config-conventional": "^17.8.0",
|
|
132
|
+
"@types/babel__core": "^7.20.3",
|
|
133
|
+
"@types/cpx": "^1.5.4",
|
|
134
|
+
"@types/find-config": "^1.0.3",
|
|
135
|
+
"@types/git-url-parse": "^9.0.2",
|
|
136
|
+
"@types/node": "^20.8.7",
|
|
137
|
+
"@types/parse-git-config": "^3.0.3",
|
|
138
|
+
"@types/prompts": "^2.4.7",
|
|
177
139
|
"@types/rimraf": "^3.0.2",
|
|
178
|
-
"@types/treeify": "^1.0.
|
|
179
|
-
"@types/uuid": "^9.0.
|
|
180
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
181
|
-
"@typescript-eslint/parser": "^6.
|
|
140
|
+
"@types/treeify": "^1.0.2",
|
|
141
|
+
"@types/uuid": "^9.0.5",
|
|
142
|
+
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
143
|
+
"@typescript-eslint/parser": "^6.8.0",
|
|
182
144
|
"commitizen": "^4.3.0",
|
|
183
145
|
"cpx": "^1.5.0",
|
|
184
146
|
"cz-conventional-changelog": "^3.3.0",
|
|
185
147
|
"eslint": "^8.51.0",
|
|
186
148
|
"eslint-config-prettier": "^9.0.0",
|
|
187
149
|
"eslint-plugin-import": "^2.28.1",
|
|
188
|
-
"eslint-plugin-prettier": "^5.0.
|
|
150
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
189
151
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
190
152
|
"husky": "^8.0.3",
|
|
191
|
-
"lint-staged": "^
|
|
153
|
+
"lint-staged": "^15.0.1",
|
|
192
154
|
"npm-run-all": "^4.1.5",
|
|
193
155
|
"outdent": "^0.8.0",
|
|
194
156
|
"recast": "^0.23.4",
|
|
195
157
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
196
|
-
"semantic-release": "^21.1.2",
|
|
197
158
|
"ts-node": "^10.9.1",
|
|
198
159
|
"typescript": "^5.2.2",
|
|
199
160
|
"vitest": "^0.34.6",
|
|
200
|
-
"vitest-github-actions-reporter": "^0.10.0"
|
|
161
|
+
"vitest-github-actions-reporter": "^0.10.0",
|
|
162
|
+
"@sanity/pkg-utils": "3.1.1"
|
|
201
163
|
},
|
|
202
164
|
"peerDependencies": {
|
|
203
165
|
"typescript": "^4.7 || ^5"
|
|
204
166
|
},
|
|
205
|
-
"packageManager": "pnpm@8.
|
|
167
|
+
"packageManager": "pnpm@8.9.2",
|
|
206
168
|
"engines": {
|
|
207
169
|
"node": ">=16.0.0"
|
|
208
170
|
},
|
|
209
171
|
"publishConfig": {
|
|
210
|
-
"access": "public"
|
|
211
|
-
"provenance": true
|
|
172
|
+
"access": "public"
|
|
212
173
|
},
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
|
|
216
|
-
|
|
174
|
+
"scripts": {
|
|
175
|
+
"build": "run-s clean build:pkg check:pkg",
|
|
176
|
+
"build:pkg": "node --loader esbuild-register/loader -r esbuild-register scripts/build",
|
|
177
|
+
"check:pkg": "node --loader esbuild-register/loader -r esbuild-register scripts/check",
|
|
178
|
+
"check:types": "tsc --build",
|
|
179
|
+
"clean": "rimraf dist",
|
|
180
|
+
"commit": "cz",
|
|
181
|
+
"extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
|
|
182
|
+
"format": "prettier --write --cache --ignore-unknown . && eslint . --ext .cjs,.js,.ts,.tsx --fix --quiet",
|
|
183
|
+
"lint": "eslint . --ext .cjs,.js,.ts,.tsx",
|
|
184
|
+
"playground:build": "pnpm --filter './playground/**' build",
|
|
185
|
+
"playground:clean": "pnpm --filter './playground/**' --silent clean",
|
|
186
|
+
"test": "run-s playground:clean test:clean vitest:run",
|
|
187
|
+
"test:clean": "rimraf test/env/__tmp__",
|
|
188
|
+
"vitest:run": "vitest run",
|
|
189
|
+
"watch": "node --loader esbuild-register/loader -r esbuild-register scripts/watch"
|
|
217
190
|
}
|
|
218
|
-
}
|
|
191
|
+
}
|
|
@@ -114,11 +114,6 @@ export interface PkgConfigOptions {
|
|
|
114
114
|
* Build package with support for legacy exports (writes root `<export>.js` files)
|
|
115
115
|
*/
|
|
116
116
|
legacyExports?: boolean
|
|
117
|
-
/**
|
|
118
|
-
* Preserves module directives, such as `'use client'`
|
|
119
|
-
* @alpha
|
|
120
|
-
*/
|
|
121
|
-
preserveModuleDirectives?: boolean
|
|
122
117
|
minify?: boolean
|
|
123
118
|
/** @alpha */
|
|
124
119
|
rollup?: {
|
|
@@ -8,7 +8,6 @@ import terser from '@rollup/plugin-terser'
|
|
|
8
8
|
import path from 'path'
|
|
9
9
|
import {InputOptions, OutputOptions, Plugin} from 'rollup'
|
|
10
10
|
import esbuild from 'rollup-plugin-esbuild'
|
|
11
|
-
import preserveDirectives from 'rollup-plugin-preserve-directives'
|
|
12
11
|
|
|
13
12
|
import {BuildContext, DEFAULT_BROWSERSLIST_QUERY, resolveConfigProperty} from '../../core'
|
|
14
13
|
import {RollupTask, RollupWatchTask} from '../types'
|
|
@@ -112,12 +111,7 @@ export function resolveRollupConfig(
|
|
|
112
111
|
}),
|
|
113
112
|
minify &&
|
|
114
113
|
terser({
|
|
115
|
-
compress:
|
|
116
|
-
? {
|
|
117
|
-
// Needed until https://github.com/terser/terser/issues/1320 is fixed
|
|
118
|
-
directives: false,
|
|
119
|
-
}
|
|
120
|
-
: true,
|
|
114
|
+
compress: true,
|
|
121
115
|
output: {
|
|
122
116
|
comments: (_node, comment) => {
|
|
123
117
|
const text = comment.value
|
|
@@ -133,8 +127,6 @@ export function resolveRollupConfig(
|
|
|
133
127
|
},
|
|
134
128
|
},
|
|
135
129
|
}),
|
|
136
|
-
// Allows marking export files with `'use client'` at the top
|
|
137
|
-
config?.preserveModuleDirectives && preserveDirectives(),
|
|
138
130
|
].filter(Boolean) as Plugin[]
|
|
139
131
|
|
|
140
132
|
const userPlugins = config?.rollup?.plugins
|
|
@@ -184,6 +176,12 @@ export function resolveRollupConfig(
|
|
|
184
176
|
return {...acc, [entry.name]: entry.source}
|
|
185
177
|
}, {}),
|
|
186
178
|
|
|
179
|
+
watch: {
|
|
180
|
+
chokidar: {
|
|
181
|
+
usePolling: true,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
|
|
187
185
|
plugins,
|
|
188
186
|
|
|
189
187
|
treeshake: {
|
|
@@ -217,7 +215,6 @@ export function resolveRollupConfig(
|
|
|
217
215
|
minifyInternalExports: minify,
|
|
218
216
|
sourcemap: config?.sourcemap ?? true,
|
|
219
217
|
hoistTransitiveImports: false,
|
|
220
|
-
preserveModules: config?.preserveModuleDirectives ? true : false,
|
|
221
218
|
},
|
|
222
219
|
}
|
|
223
220
|
}
|
|
@@ -114,26 +114,6 @@ async function execPromise(ctx: BuildContext, task: RollupTask) {
|
|
|
114
114
|
const bundle = await rollup({
|
|
115
115
|
...inputOptions,
|
|
116
116
|
onwarn(warning) {
|
|
117
|
-
if (
|
|
118
|
-
// Ignore the directive warning until the preserveDirectives plugin does it automatically: https://github.com/Ephem/rollup-plugin-preserve-directives#rollup-plugin-preserve-directives-warning
|
|
119
|
-
warning.message.includes(
|
|
120
|
-
'Module level directives cause errors when bundled, "use client" in',
|
|
121
|
-
)
|
|
122
|
-
) {
|
|
123
|
-
// If the preserve option isn't enabled, then extend the message with a note about how to enable
|
|
124
|
-
if (!ctx.config?.preserveModuleDirectives) {
|
|
125
|
-
consoleSpy.messages.push({
|
|
126
|
-
type: 'warn',
|
|
127
|
-
code: warning.code,
|
|
128
|
-
args: [
|
|
129
|
-
`${warning.message} You can preserve it by setting "preserveModuleDirectives: true" in your "package.config.ts"`,
|
|
130
|
-
],
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
|
|
137
117
|
consoleSpy.messages.push({
|
|
138
118
|
type: 'warn',
|
|
139
119
|
code: warning.code,
|