@sanity/pkg-utils 2.3.12 → 2.3.13-canary.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-11470607.cjs → build-fabfa3af.cjs} +6 -6
- package/dist/_chunks/build-fabfa3af.cjs.map +1 -0
- package/dist/_chunks/{buildAction-e950d498.cjs → buildAction-dae78abb.cjs} +2 -2
- package/dist/_chunks/{buildAction-e950d498.cjs.map → buildAction-dae78abb.cjs.map} +1 -1
- package/dist/_chunks/{check-0665cb35.cjs → check-332a2bb9.cjs} +3 -3
- package/dist/_chunks/{check-0665cb35.cjs.map → check-332a2bb9.cjs.map} +1 -1
- package/dist/_chunks/{checkAction-c3e5da35.cjs → checkAction-c39d7dbf.cjs} +2 -2
- package/dist/_chunks/{checkAction-c3e5da35.cjs.map → checkAction-c39d7dbf.cjs.map} +1 -1
- package/dist/_chunks/{consoleSpy-d738cb9f.cjs → consoleSpy-686c350b.cjs} +52 -12
- package/dist/_chunks/consoleSpy-686c350b.cjs.map +1 -0
- package/dist/_chunks/{index-70f8931a.cjs → index-1811ae9f.cjs} +25 -7
- package/dist/_chunks/index-1811ae9f.cjs.map +1 -0
- package/dist/_chunks/{init-2377e6e5.cjs → init-e45c0c31.cjs} +2 -2
- package/dist/_chunks/{init-2377e6e5.cjs.map → init-e45c0c31.cjs.map} +1 -1
- package/dist/_chunks/{initAction-2abd8576.cjs → initAction-48ce747a.cjs} +2 -2
- package/dist/_chunks/{initAction-2abd8576.cjs.map → initAction-48ce747a.cjs.map} +1 -1
- package/dist/_chunks/{logger-c593f06b.cjs → logger-718e11be.cjs} +8 -6
- package/dist/_chunks/logger-718e11be.cjs.map +1 -0
- package/dist/_chunks/{watch-d390d5e4.cjs → watch-4e565bee.cjs} +4 -4
- package/dist/_chunks/{watch-d390d5e4.cjs.map → watch-4e565bee.cjs.map} +1 -1
- package/dist/_chunks/{watchAction-63c8a721.cjs → watchAction-a5721084.cjs} +2 -2
- package/dist/_chunks/{watchAction-63c8a721.cjs.map → watchAction-a5721084.cjs.map} +1 -1
- package/dist/cli.cjs +5 -5
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +9 -2
- package/dist/index.js +80 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/node/core/config/types.ts +5 -0
- package/src/node/core/pkg/loadPkgWithReporting.ts +91 -18
- package/src/node/core/pkg/types.ts +4 -2
- package/src/node/core/pkg/validatePkg.ts +5 -3
- package/src/node/resolveBuildTasks.ts +2 -2
- package/src/node/tasks/rollup/resolveRollupConfig.ts +10 -4
- package/src/node/tasks/rollup/rollupTask.ts +20 -0
- package/dist/_chunks/build-11470607.cjs.map +0 -1
- package/dist/_chunks/consoleSpy-d738cb9f.cjs.map +0 -1
- package/dist/_chunks/index-70f8931a.cjs.map +0 -1
- package/dist/_chunks/logger-c593f06b.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchAction-
|
|
1
|
+
{"version":3,"file":"watchAction-a5721084.cjs","sources":["../../src/cli/watchAction.ts"],"sourcesContent":["import {watch} from '../node/watch'\nimport {handleError} from './handleError'\n\nexport async function watchAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await watch({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"names":["watchAction","options","watch","cwd","process","strict","tsconfig","err","handleError"],"mappings":";;;;AAGA,eAAsBA,YAAYC,OAA+D,EAAA;EAC3F,IAAA;IACF,MAAMC,WAAM,CAAA;MACVC,GAAA,EAAKC,QAAQD,GAAI,CAAA,CAAA;MACjBE,QAAQJ,OAAQ,CAAAI,MAAA;MAChBC,UAAUL,OAAQ,CAAAK;IAAA,CACnB,CAAA;WACMC,GAAK,EAAA;IACZC,WAAA,CAAAA,WAAA,CAAYD,GAAG,CAAA;EACjB;AACF;"}
|
package/dist/cli.cjs
CHANGED
|
@@ -7,13 +7,13 @@ function _interopDefaultCompat(e) {
|
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
var cac__default = /*#__PURE__*/_interopDefaultCompat(cac);
|
|
10
|
-
var version = "2.3.
|
|
10
|
+
var version = "2.3.13-canary.1";
|
|
11
11
|
const cli = cac__default.default();
|
|
12
12
|
cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async options => {
|
|
13
13
|
const {
|
|
14
14
|
checkAction
|
|
15
15
|
} = await Promise.resolve().then(function () {
|
|
16
|
-
return require('./_chunks/checkAction-
|
|
16
|
+
return require('./_chunks/checkAction-c39d7dbf.cjs');
|
|
17
17
|
});
|
|
18
18
|
return checkAction(options);
|
|
19
19
|
});
|
|
@@ -21,7 +21,7 @@ cli.command("build", "Build package").option("--emitDeclarationOnly", "Emit d.ts
|
|
|
21
21
|
const {
|
|
22
22
|
buildAction
|
|
23
23
|
} = await Promise.resolve().then(function () {
|
|
24
|
-
return require('./_chunks/buildAction-
|
|
24
|
+
return require('./_chunks/buildAction-dae78abb.cjs');
|
|
25
25
|
});
|
|
26
26
|
return buildAction(options);
|
|
27
27
|
});
|
|
@@ -29,7 +29,7 @@ cli.command("init [path]", "Initialize package").action(async p => {
|
|
|
29
29
|
const {
|
|
30
30
|
initAction
|
|
31
31
|
} = await Promise.resolve().then(function () {
|
|
32
|
-
return require('./_chunks/initAction-
|
|
32
|
+
return require('./_chunks/initAction-48ce747a.cjs');
|
|
33
33
|
});
|
|
34
34
|
return initAction({
|
|
35
35
|
path: p
|
|
@@ -39,7 +39,7 @@ cli.command("watch", "Watch package").option("--strict", "Strict mode").option("
|
|
|
39
39
|
const {
|
|
40
40
|
watchAction
|
|
41
41
|
} = await Promise.resolve().then(function () {
|
|
42
|
-
return require('./_chunks/watchAction-
|
|
42
|
+
return require('./_chunks/watchAction-a5721084.cjs');
|
|
43
43
|
});
|
|
44
44
|
return watchAction(options);
|
|
45
45
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var build = require('./_chunks/build-
|
|
7
|
-
var check = require('./_chunks/check-
|
|
8
|
-
var consoleSpy = require('./_chunks/consoleSpy-
|
|
9
|
-
var logger = require('./_chunks/logger-
|
|
10
|
-
var init = require('./_chunks/init-
|
|
11
|
-
var index = require('./_chunks/index-
|
|
12
|
-
var watch = require('./_chunks/watch-
|
|
6
|
+
var build = require('./_chunks/build-fabfa3af.cjs');
|
|
7
|
+
var check = require('./_chunks/check-332a2bb9.cjs');
|
|
8
|
+
var consoleSpy = require('./_chunks/consoleSpy-686c350b.cjs');
|
|
9
|
+
var logger = require('./_chunks/logger-718e11be.cjs');
|
|
10
|
+
var init = require('./_chunks/init-e45c0c31.cjs');
|
|
11
|
+
var index = require('./_chunks/index-1811ae9f.cjs');
|
|
12
|
+
var watch = require('./_chunks/watch-4e565bee.cjs');
|
|
13
13
|
function defineConfig(configOptions) {
|
|
14
14
|
return configOptions;
|
|
15
15
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -218,14 +218,16 @@ export declare interface PackageJSON {
|
|
|
218
218
|
types?: string
|
|
219
219
|
browser?: {
|
|
220
220
|
source: string
|
|
221
|
-
require?: string
|
|
222
221
|
import?: string
|
|
222
|
+
require?: string
|
|
223
223
|
}
|
|
224
224
|
node?: {
|
|
225
225
|
source?: string
|
|
226
|
-
|
|
226
|
+
module?: string
|
|
227
227
|
import?: string
|
|
228
|
+
require?: string
|
|
228
229
|
}
|
|
230
|
+
module?: string
|
|
229
231
|
import?: string
|
|
230
232
|
require?: string
|
|
231
233
|
default: string
|
|
@@ -326,6 +328,11 @@ export declare interface PkgConfigOptions {
|
|
|
326
328
|
* Build package with support for legacy exports (writes root `<export>.js` files)
|
|
327
329
|
*/
|
|
328
330
|
legacyExports?: boolean
|
|
331
|
+
/**
|
|
332
|
+
* Preserves module directives, such as `'use client'`
|
|
333
|
+
* @alpha
|
|
334
|
+
*/
|
|
335
|
+
preserveModuleDirectives?: boolean
|
|
329
336
|
minify?: boolean
|
|
330
337
|
/** @alpha */
|
|
331
338
|
rollup?: {
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
|
32
32
|
import replace from '@rollup/plugin-replace';
|
|
33
33
|
import terser from '@rollup/plugin-terser';
|
|
34
34
|
import esbuild from 'rollup-plugin-esbuild';
|
|
35
|
+
import preserveDirectives from 'rollup-plugin-preserve-directives';
|
|
35
36
|
import esbuild$1 from 'esbuild';
|
|
36
37
|
import treeify from 'treeify';
|
|
37
38
|
import prettyBytes from 'pretty-bytes';
|
|
@@ -125,18 +126,20 @@ const pkgSchema = z.object({
|
|
|
125
126
|
exports: z.optional(z.record(z.union([z.custom(val => /^\.\/.*\.json$/.test(val)), z.object({
|
|
126
127
|
types: z.optional(z.string()),
|
|
127
128
|
source: z.string(),
|
|
128
|
-
require: z.optional(z.string()),
|
|
129
129
|
browser: z.optional(z.object({
|
|
130
130
|
source: z.string(),
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
import: z.optional(z.string()),
|
|
132
|
+
require: z.optional(z.string())
|
|
133
133
|
})),
|
|
134
134
|
node: z.optional(z.object({
|
|
135
135
|
source: z.optional(z.string()),
|
|
136
|
-
|
|
137
|
-
import: z.optional(z.string())
|
|
136
|
+
module: z.optional(z.string()),
|
|
137
|
+
import: z.optional(z.string()),
|
|
138
|
+
require: z.optional(z.string())
|
|
138
139
|
})),
|
|
140
|
+
module: z.optional(z.string()),
|
|
139
141
|
import: z.optional(z.string()),
|
|
142
|
+
require: z.optional(z.string()),
|
|
140
143
|
default: z.string()
|
|
141
144
|
})]))),
|
|
142
145
|
browserslist: z.optional(z.array(z.string()))
|
|
@@ -188,6 +191,7 @@ async function loadPkgWithReporting(options) {
|
|
|
188
191
|
const pkg = await loadPkg({
|
|
189
192
|
cwd
|
|
190
193
|
});
|
|
194
|
+
let shouldError = false;
|
|
191
195
|
if (pkg.exports) {
|
|
192
196
|
const _exports = Object.entries(pkg.exports);
|
|
193
197
|
for (const [expPath, exp] of _exports) {
|
|
@@ -196,22 +200,61 @@ async function loadPkgWithReporting(options) {
|
|
|
196
200
|
}
|
|
197
201
|
const keys = Object.keys(exp);
|
|
198
202
|
if (!assertFirst("types", keys)) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (!assertOrder("require", "import", keys)) {
|
|
202
|
-
logger.warn("exports[\"".concat(expPath, "\"]: the `require` property should come before the `import` property"));
|
|
203
|
+
shouldError = true;
|
|
204
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `types` property should be the first property"));
|
|
203
205
|
}
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
if (exp.node) {
|
|
207
|
+
const nodeKeys = Object.keys(exp.node);
|
|
208
|
+
if (!assertOrder("module", "import", nodeKeys)) {
|
|
209
|
+
shouldError = true;
|
|
210
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `node.module` property should come before the `node.import` property"));
|
|
211
|
+
}
|
|
212
|
+
if (!assertOrder("import", "require", nodeKeys)) {
|
|
213
|
+
logger.warn("exports[\"".concat(expPath, "\"]: the `node.import` property should come before the `node.require` property"));
|
|
214
|
+
}
|
|
215
|
+
if (!assertOrder("module", "require", nodeKeys)) {
|
|
216
|
+
logger.warn("exports[\"".concat(expPath, "\"]: the `node.module` property should come before `node.require` property"));
|
|
217
|
+
}
|
|
218
|
+
if (exp.import && exp.node.import && !assertOrder("node", "import", keys)) {
|
|
219
|
+
shouldError = true;
|
|
220
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `node` property should come before the `import` property"));
|
|
221
|
+
}
|
|
222
|
+
if (exp.module && exp.node.module && !assertOrder("node", "module", keys)) {
|
|
223
|
+
shouldError = true;
|
|
224
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `node` property should come before the `module` property"));
|
|
225
|
+
}
|
|
226
|
+
if (exp.node.import && !exp.node.require && !exp.node.module) {
|
|
227
|
+
shouldError = true;
|
|
228
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `node.module` property should be added so bundlers don't unintentionally try to bundle `node.import`"));
|
|
229
|
+
}
|
|
230
|
+
if (exp.node.import && !exp.node.require && exp.node.module && exp.import && exp.node.module !== exp.import) {
|
|
231
|
+
shouldError = true;
|
|
232
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `node.module` property should match `import`"));
|
|
233
|
+
}
|
|
234
|
+
if (exp.require && exp.node.require && exp.require === exp.node.require) {
|
|
235
|
+
shouldError = true;
|
|
236
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `node.require` property isn't necessary as it's identical to `require`"));
|
|
237
|
+
} else if (exp.require && exp.node.require && !assertOrder("node", "require", keys)) {
|
|
238
|
+
shouldError = true;
|
|
239
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `node` property should come before the `require` property"));
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
if (!assertOrder("import", "require", keys)) {
|
|
243
|
+
logger.warn("exports[\"".concat(expPath, "\"]: the `import` property should come before the `require` property"));
|
|
244
|
+
}
|
|
245
|
+
if (!assertOrder("module", "import", keys)) {
|
|
246
|
+
logger.warn("exports[\"".concat(expPath, "\"]: the `module` property should come before `import` property"));
|
|
247
|
+
}
|
|
209
248
|
}
|
|
210
249
|
if (!assertLast("default", keys)) {
|
|
211
|
-
|
|
250
|
+
shouldError = true;
|
|
251
|
+
logger.error("exports[\"".concat(expPath, "\"]: the `default` property should be the last property"));
|
|
212
252
|
}
|
|
213
253
|
}
|
|
214
254
|
}
|
|
255
|
+
if (shouldError) {
|
|
256
|
+
process.exit(1);
|
|
257
|
+
}
|
|
215
258
|
return pkg;
|
|
216
259
|
} catch (err) {
|
|
217
260
|
if (err instanceof ZodError) {
|
|
@@ -765,12 +808,12 @@ function resolveBuildTasks(ctx) {
|
|
|
765
808
|
}
|
|
766
809
|
const nodeReexportCjsEntries = [];
|
|
767
810
|
for (const exp of exports) {
|
|
768
|
-
if (exp.node && !exp.node.source && exp.node.import && exp.node.require && (exp.node.import.endsWith(".cjs.js") || exp.node.import.endsWith(".cjs.mjs"))) {
|
|
811
|
+
if (exp.node && !exp.node.source && exp.node.import && (exp.node.require || exp.require) && (exp.node.import.endsWith(".cjs.js") || exp.node.import.endsWith(".cjs.mjs"))) {
|
|
769
812
|
const importId = path.join(pkg.name, exp._path);
|
|
770
813
|
nodeReexportCjsEntries.push({
|
|
771
814
|
importId,
|
|
772
815
|
import: exp.node.import,
|
|
773
|
-
require: exp.node.require
|
|
816
|
+
require: exp.node.require || exp.require
|
|
774
817
|
});
|
|
775
818
|
}
|
|
776
819
|
}
|
|
@@ -1415,10 +1458,10 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
1415
1458
|
modules: false
|
|
1416
1459
|
}]]
|
|
1417
1460
|
}), minify && terser({
|
|
1418
|
-
compress: {
|
|
1461
|
+
compress: (config == null ? void 0 : config.preserveModuleDirectives) ? {
|
|
1419
1462
|
// Needed until https://github.com/terser/terser/issues/1320 is fixed
|
|
1420
1463
|
directives: false
|
|
1421
|
-
},
|
|
1464
|
+
} : true,
|
|
1422
1465
|
output: {
|
|
1423
1466
|
comments: (_node, comment) => {
|
|
1424
1467
|
const text = comment.value;
|
|
@@ -1429,7 +1472,9 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
1429
1472
|
return false;
|
|
1430
1473
|
}
|
|
1431
1474
|
}
|
|
1432
|
-
})
|
|
1475
|
+
}),
|
|
1476
|
+
// Allows marking export files with `'use client'` at the top
|
|
1477
|
+
(config == null ? void 0 : config.preserveModuleDirectives) && preserveDirectives()].filter(Boolean);
|
|
1433
1478
|
const userPlugins = (_c = config == null ? void 0 : config.rollup) == null ? void 0 : _c.plugins;
|
|
1434
1479
|
const plugins = Array.isArray(userPlugins) ? defaultPlugins.concat(userPlugins) : resolveConfigProperty((_d = config == null ? void 0 : config.rollup) == null ? void 0 : _d.plugins, defaultPlugins);
|
|
1435
1480
|
return {
|
|
@@ -1486,7 +1531,8 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
1486
1531
|
interop: "compat",
|
|
1487
1532
|
minifyInternalExports: minify,
|
|
1488
1533
|
sourcemap: (_ref11 = config == null ? void 0 : config.sourcemap) !== null && _ref11 !== void 0 ? _ref11 : true,
|
|
1489
|
-
hoistTransitiveImports: false
|
|
1534
|
+
hoistTransitiveImports: false,
|
|
1535
|
+
preserveModules: (config == null ? void 0 : config.preserveModuleDirectives) ? true : false
|
|
1490
1536
|
}
|
|
1491
1537
|
};
|
|
1492
1538
|
}
|
|
@@ -1552,6 +1598,19 @@ async function execPromise(ctx, task) {
|
|
|
1552
1598
|
const bundle = await rollup({
|
|
1553
1599
|
...inputOptions,
|
|
1554
1600
|
onwarn(warning) {
|
|
1601
|
+
var _a;
|
|
1602
|
+
if (
|
|
1603
|
+
// Ignore the directive warning until the preserveDirectives plugin does it automatically: https://github.com/Ephem/rollup-plugin-preserve-directives#rollup-plugin-preserve-directives-warning
|
|
1604
|
+
warning.message.includes('Module level directives cause errors when bundled, "use client" in')) {
|
|
1605
|
+
if (!((_a = ctx.config) == null ? void 0 : _a.preserveModuleDirectives)) {
|
|
1606
|
+
consoleSpy.messages.push({
|
|
1607
|
+
type: "warn",
|
|
1608
|
+
code: warning.code,
|
|
1609
|
+
args: ["".concat(warning.message, " You can preserve it by setting \"preserveModuleDirectives: true\" in your \"package.config.ts\"")]
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1555
1614
|
consoleSpy.messages.push({
|
|
1556
1615
|
type: "warn",
|
|
1557
1616
|
code: warning.code,
|