@sanity/pkg-utils 2.0.7 → 2.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-411f01fc.cjs → build-68e9229a.cjs} +24 -11
- package/dist/_chunks/build-68e9229a.cjs.map +1 -0
- package/dist/_chunks/{buildAction-558fce96.cjs → buildAction-9ce9614a.cjs} +2 -2
- package/dist/_chunks/{buildAction-558fce96.cjs.map → buildAction-9ce9614a.cjs.map} +1 -1
- package/dist/_chunks/{check-3bf5eb0d.cjs → check-745260bc.cjs} +2 -2
- package/dist/_chunks/{check-3bf5eb0d.cjs.map → check-745260bc.cjs.map} +1 -1
- package/dist/_chunks/{checkAction-fcfe53a1.cjs → checkAction-1aa1fff7.cjs} +2 -2
- package/dist/_chunks/{checkAction-fcfe53a1.cjs.map → checkAction-1aa1fff7.cjs.map} +1 -1
- package/dist/_chunks/{index-5e7d04c4.cjs → index-a01cf661.cjs} +82 -42
- package/dist/_chunks/index-a01cf661.cjs.map +1 -0
- package/dist/_chunks/{resolveBuildContext-86a1602c.cjs → resolveBuildContext-702e3fb6.cjs} +14 -18
- package/dist/_chunks/{resolveBuildContext-86a1602c.cjs.map → resolveBuildContext-702e3fb6.cjs.map} +1 -1
- package/dist/_chunks/{watch-096666ea.cjs → watch-533fe913.cjs} +7 -11
- package/dist/_chunks/{watch-096666ea.cjs.map → watch-533fe913.cjs.map} +1 -1
- package/dist/_chunks/{watchAction-218b780d.cjs → watchAction-d2c08880.cjs} +2 -2
- package/dist/_chunks/{watchAction-218b780d.cjs.map → watchAction-d2c08880.cjs.map} +1 -1
- package/dist/cli.cjs +4 -4
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +17 -1
- package/dist/index.js +120 -60
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/node/core/config/types.ts +5 -0
- package/src/node/resolveBuildTasks.ts +29 -1
- package/src/node/tasks/index.ts +2 -0
- package/src/node/tasks/node/reexportCjsTask.ts +63 -0
- package/src/node/tasks/rollup/resolveRollupConfig.ts +1 -1
- package/src/node/tasks/types.ts +8 -1
- package/dist/_chunks/build-411f01fc.cjs.map +0 -1
- package/dist/_chunks/index-5e7d04c4.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchAction-
|
|
1
|
+
{"version":3,"file":"watchAction-d2c08880.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,EAAA;MACjBE,QAAQJ,OAAQ,CAAAI,MAAA;MAChBC,UAAUL,OAAQ,CAAAK;IAAA,CACnB,CAAA;WACMC,GAAP,EAAA;IACAC,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.
|
|
10
|
+
var version = "2.1.1";
|
|
11
11
|
const cli = cac__default.default();
|
|
12
12
|
cli.command("", "Check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async options => {
|
|
13
13
|
const {
|
|
14
14
|
checkAction: statusAction
|
|
15
15
|
} = await Promise.resolve().then(function () {
|
|
16
|
-
return require('./_chunks/checkAction-
|
|
16
|
+
return require('./_chunks/checkAction-1aa1fff7.cjs');
|
|
17
17
|
});
|
|
18
18
|
return statusAction(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-9ce9614a.cjs');
|
|
25
25
|
});
|
|
26
26
|
return buildAction(options);
|
|
27
27
|
});
|
|
@@ -29,7 +29,7 @@ cli.command("watch", "Watch package").option("--strict", "Strict mode").option("
|
|
|
29
29
|
const {
|
|
30
30
|
watchAction
|
|
31
31
|
} = await Promise.resolve().then(function () {
|
|
32
|
-
return require('./_chunks/watchAction-
|
|
32
|
+
return require('./_chunks/watchAction-d2c08880.cjs');
|
|
33
33
|
});
|
|
34
34
|
return watchAction(options);
|
|
35
35
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
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 resolveBuildContext = require('./_chunks/resolveBuildContext-
|
|
9
|
-
var index = require('./_chunks/index-
|
|
10
|
-
var watch = require('./_chunks/watch-
|
|
6
|
+
var build = require('./_chunks/build-68e9229a.cjs');
|
|
7
|
+
var check = require('./_chunks/check-745260bc.cjs');
|
|
8
|
+
var resolveBuildContext = require('./_chunks/resolveBuildContext-702e3fb6.cjs');
|
|
9
|
+
var index = require('./_chunks/index-a01cf661.cjs');
|
|
10
|
+
var watch = require('./_chunks/watch-533fe913.cjs');
|
|
11
11
|
function defineConfig(configOptions) {
|
|
12
12
|
return configOptions;
|
|
13
13
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {ExtractorMessage} from '@microsoft/api-extractor'
|
|
2
2
|
import {IExtractorMessagesConfig} from '@microsoft/api-extractor'
|
|
3
3
|
import {Observable} from 'rxjs'
|
|
4
|
+
import {PluginItem} from '@babel/core'
|
|
4
5
|
import {Plugin as RollupPlugin} from 'rollup'
|
|
5
6
|
import {RollupWatcherEvent} from 'rollup'
|
|
6
7
|
import ts from 'typescript'
|
|
@@ -59,12 +60,13 @@ export declare interface BuildFile {
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/** @internal */
|
|
62
|
-
export declare type BuildTask = DtsTask | RollupTask
|
|
63
|
+
export declare type BuildTask = DtsTask | RollupTask | NodeReExportFromCJSTask
|
|
63
64
|
|
|
64
65
|
/** @internal */
|
|
65
66
|
export declare interface BuildTaskHandlers {
|
|
66
67
|
'build:dts': TaskHandler<DtsTask, DtsResult>
|
|
67
68
|
'build:js': TaskHandler<RollupTask>
|
|
69
|
+
'node:reexport-cjs': TaskHandler<NodeReExportFromCJSTask>
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
/** @internal */
|
|
@@ -165,6 +167,16 @@ export declare interface Logger {
|
|
|
165
167
|
success: (...args: unknown[]) => void
|
|
166
168
|
}
|
|
167
169
|
|
|
170
|
+
/** @internal */
|
|
171
|
+
export declare interface NodeReExportFromCJSTask {
|
|
172
|
+
type: 'node:reexport-cjs'
|
|
173
|
+
entries: {
|
|
174
|
+
importId: string
|
|
175
|
+
import: string
|
|
176
|
+
require: string
|
|
177
|
+
}[]
|
|
178
|
+
}
|
|
179
|
+
|
|
168
180
|
/** @internal */
|
|
169
181
|
export declare interface PackageJSON {
|
|
170
182
|
type?: 'commonjs' | 'module'
|
|
@@ -223,6 +235,10 @@ export declare interface PkgBundle {
|
|
|
223
235
|
|
|
224
236
|
/** @public */
|
|
225
237
|
export declare interface PkgConfigOptions {
|
|
238
|
+
/** @alpha */
|
|
239
|
+
babel?: {
|
|
240
|
+
plugins?: PluginItem[] | null | undefined
|
|
241
|
+
}
|
|
226
242
|
bundles?: PkgBundle[]
|
|
227
243
|
/** @alpha */
|
|
228
244
|
define?: Record<string, string | number | boolean | undefined | null>
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
const _excluded = ["_path"];
|
|
2
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
8
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
1
|
import path from 'path';
|
|
10
2
|
import { register } from 'esbuild-register/dist/node';
|
|
11
3
|
import pkgUp from 'pkg-up';
|
|
12
|
-
import fs, { stat, readFile } from 'fs/promises';
|
|
4
|
+
import fs, { stat, readFile, writeFile } from 'fs/promises';
|
|
13
5
|
import findConfig from 'find-config';
|
|
14
6
|
import { z, ZodError } from 'zod';
|
|
15
7
|
import chalk from 'chalk';
|
|
16
8
|
import ts from 'typescript';
|
|
17
9
|
import browserslist from 'browserslist';
|
|
18
10
|
import fs$1, { statSync } from 'fs';
|
|
19
|
-
import { Observable, switchMap } from 'rxjs';
|
|
11
|
+
import { Observable, from, switchMap } from 'rxjs';
|
|
20
12
|
import { promisify } from 'util';
|
|
21
13
|
import rimrafCallback from 'rimraf';
|
|
22
14
|
import { ExtractorConfig, Extractor } from '@microsoft/api-extractor';
|
|
@@ -260,10 +252,11 @@ function parseExports(options) {
|
|
|
260
252
|
}
|
|
261
253
|
Object.assign(rootExport, exportEntry);
|
|
262
254
|
} else {
|
|
263
|
-
const extraExport =
|
|
255
|
+
const extraExport = {
|
|
264
256
|
_exported: true,
|
|
265
|
-
_path: exportPath
|
|
266
|
-
|
|
257
|
+
_path: exportPath,
|
|
258
|
+
...exportEntry
|
|
259
|
+
};
|
|
267
260
|
extraExports.push(extraExport);
|
|
268
261
|
}
|
|
269
262
|
} else {
|
|
@@ -295,7 +288,9 @@ function getPkgExtMap(options) {
|
|
|
295
288
|
const {
|
|
296
289
|
legacyExports
|
|
297
290
|
} = options;
|
|
298
|
-
const ret =
|
|
291
|
+
const ret = {
|
|
292
|
+
...DEFAULT_PKG_EXT_MAP
|
|
293
|
+
};
|
|
299
294
|
if (legacyExports) {
|
|
300
295
|
ret["commonjs"] = {
|
|
301
296
|
commonjs: ".js",
|
|
@@ -484,12 +479,13 @@ async function resolveBuildContext(options) {
|
|
|
484
479
|
strict
|
|
485
480
|
}).reduce((acc, x) => {
|
|
486
481
|
const {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return
|
|
482
|
+
_path: exportPath,
|
|
483
|
+
...exportEntry
|
|
484
|
+
} = x;
|
|
485
|
+
return {
|
|
486
|
+
...acc,
|
|
491
487
|
[exportPath]: exportEntry
|
|
492
|
-
}
|
|
488
|
+
};
|
|
493
489
|
}, {});
|
|
494
490
|
const exports = resolveConfigProperty(config == null ? void 0 : config.exports, parsedExports);
|
|
495
491
|
const parsedExternal = [...(pkg.dependencies ? Object.keys(pkg.dependencies) : []), ...(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [])];
|
|
@@ -547,9 +543,10 @@ function resolveBuildTasks(ctx) {
|
|
|
547
543
|
const tasks = [];
|
|
548
544
|
const exports = Object.entries(ctx.exports || {}).map(_ref2 => {
|
|
549
545
|
let [_path, exp] = _ref2;
|
|
550
|
-
return
|
|
551
|
-
_path
|
|
552
|
-
|
|
546
|
+
return {
|
|
547
|
+
_path,
|
|
548
|
+
...exp
|
|
549
|
+
};
|
|
553
550
|
});
|
|
554
551
|
const dtsTask = {
|
|
555
552
|
type: "build:dts",
|
|
@@ -650,6 +647,23 @@ function resolveBuildTasks(ctx) {
|
|
|
650
647
|
}
|
|
651
648
|
}
|
|
652
649
|
}
|
|
650
|
+
const nodeReexportCjsEntries = [];
|
|
651
|
+
for (const exp of exports) {
|
|
652
|
+
if (exp.node && !exp.node.source && exp.node.import && exp.node.require && (exp.node.import.endsWith(".cjs.js") || exp.node.import.endsWith(".cjs.mjs"))) {
|
|
653
|
+
const importId = path.join(pkg.name, exp._path);
|
|
654
|
+
nodeReexportCjsEntries.push({
|
|
655
|
+
importId,
|
|
656
|
+
import: exp.node.import,
|
|
657
|
+
require: exp.node.require
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (nodeReexportCjsEntries.length) {
|
|
662
|
+
tasks.push({
|
|
663
|
+
type: "node:reexport-cjs",
|
|
664
|
+
entries: nodeReexportCjsEntries
|
|
665
|
+
});
|
|
666
|
+
}
|
|
653
667
|
return tasks;
|
|
654
668
|
}
|
|
655
669
|
function createSpinner(msg) {
|
|
@@ -730,13 +744,14 @@ async function buildTypes(options) {
|
|
|
730
744
|
tsconfig,
|
|
731
745
|
strict = false
|
|
732
746
|
} = options;
|
|
733
|
-
const compilerOptions =
|
|
747
|
+
const compilerOptions = {
|
|
748
|
+
...tsconfig.options,
|
|
734
749
|
declaration: true,
|
|
735
750
|
declarationDir: outDir,
|
|
736
751
|
emitDeclarationOnly: true,
|
|
737
752
|
noEmit: false,
|
|
738
753
|
outDir
|
|
739
|
-
}
|
|
754
|
+
};
|
|
740
755
|
const program = ts.createProgram(tsconfig.fileNames, compilerOptions);
|
|
741
756
|
const emitResult = program.emit();
|
|
742
757
|
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
@@ -810,15 +825,18 @@ async function createTSDocConfig(opts) {
|
|
|
810
825
|
syntaxKind: t.syntaxKind,
|
|
811
826
|
allowMultiple: t.allowMultiple
|
|
812
827
|
})));
|
|
813
|
-
const supportForTags =
|
|
828
|
+
const supportForTags = {
|
|
829
|
+
...tsDocBaseConfig.supportForTags
|
|
830
|
+
};
|
|
814
831
|
for (const customTag of customTags) {
|
|
815
832
|
supportForTags["@".concat(customTag.name)] = true;
|
|
816
833
|
}
|
|
817
|
-
return TSDocConfigFile.loadFromObject(
|
|
834
|
+
return TSDocConfigFile.loadFromObject({
|
|
835
|
+
...tsDocBaseConfig,
|
|
818
836
|
noStandardTags: false,
|
|
819
837
|
tagDefinitions,
|
|
820
838
|
supportForTags
|
|
821
|
-
})
|
|
839
|
+
});
|
|
822
840
|
}
|
|
823
841
|
async function extractModuleBlocksFromTypes(_ref3) {
|
|
824
842
|
let {
|
|
@@ -958,9 +976,10 @@ async function extractTypes(options) {
|
|
|
958
976
|
tsOutDir: tmpPath
|
|
959
977
|
});
|
|
960
978
|
const code = [typesBuf.toString(), ...moduleBlocks].join("\n\n");
|
|
961
|
-
await fs.writeFile(typesPath, prettier.format(code,
|
|
979
|
+
await fs.writeFile(typesPath, prettier.format(code, {
|
|
980
|
+
...prettierConfig,
|
|
962
981
|
filepath: typesPath
|
|
963
|
-
}))
|
|
982
|
+
}));
|
|
964
983
|
files.push({
|
|
965
984
|
type: "types",
|
|
966
985
|
path: typesPath
|
|
@@ -1095,6 +1114,34 @@ const dtsWatchTask = {
|
|
|
1095
1114
|
}
|
|
1096
1115
|
}
|
|
1097
1116
|
};
|
|
1117
|
+
const nodeReexportCjsTask = {
|
|
1118
|
+
name: (_ctx, task) => ["Re-export CommonJS module in ESM wrapper\u2026", " entries:", ...task.entries.map(entry => [" - ".concat(chalk.cyan(entry.importId), ": "), "".concat(chalk.yellow(entry.require), " ").concat(chalk.gray("\u2192"), " ").concat(chalk.yellow(entry.import))].join(""))].join("\n"),
|
|
1119
|
+
exec: (ctx, task) => {
|
|
1120
|
+
return from(exec(ctx, task));
|
|
1121
|
+
},
|
|
1122
|
+
complete: () => {},
|
|
1123
|
+
error: (_ctx, _task, err) => {
|
|
1124
|
+
console.error(err);
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
async function exec(ctx, task) {
|
|
1128
|
+
const {
|
|
1129
|
+
cwd
|
|
1130
|
+
} = ctx;
|
|
1131
|
+
for (const entry of task.entries) {
|
|
1132
|
+
const sourcePath = path.resolve(cwd, entry.require);
|
|
1133
|
+
const targetPath = path.resolve(cwd, entry.import);
|
|
1134
|
+
const targetDir = path.dirname(targetPath);
|
|
1135
|
+
await mkdirp(targetDir);
|
|
1136
|
+
const mod = require(sourcePath);
|
|
1137
|
+
let relativeImport = "./".concat(path.relative(targetDir, sourcePath));
|
|
1138
|
+
if (relativeImport.startsWith("./.")) {
|
|
1139
|
+
relativeImport = relativeImport.slice(2);
|
|
1140
|
+
}
|
|
1141
|
+
const code = ["import cjs from '".concat(relativeImport, "';"), "", ...Object.keys(mod).map(k => "export const ".concat(k, " = cjs.").concat(k, ";")), ""].join("\n");
|
|
1142
|
+
await writeFile(targetPath, code, "utf8");
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1098
1145
|
function createConsoleSpy(options) {
|
|
1099
1146
|
const {
|
|
1100
1147
|
onRestored
|
|
@@ -1144,7 +1191,7 @@ function createConsoleSpy(options) {
|
|
|
1144
1191
|
}
|
|
1145
1192
|
function resolveRollupConfig(ctx, buildTask) {
|
|
1146
1193
|
var _ref4, _ref7, _ref8, _ref9, _ref10, _ref11;
|
|
1147
|
-
var _a, _b, _c;
|
|
1194
|
+
var _a, _b, _c, _d;
|
|
1148
1195
|
const {
|
|
1149
1196
|
format,
|
|
1150
1197
|
runtime,
|
|
@@ -1170,9 +1217,10 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
1170
1217
|
return [key, path.resolve(cwd, ((_a2 = ts.config) == null ? void 0 : _a2.options.baseUrl) || ".", val[0])];
|
|
1171
1218
|
}));
|
|
1172
1219
|
const entries = buildTask.entries.map(entry => {
|
|
1173
|
-
return
|
|
1220
|
+
return {
|
|
1221
|
+
...entry,
|
|
1174
1222
|
name: path.relative(outDir, entry.output).replace(/\.[^/.]+$/, "")
|
|
1175
|
-
}
|
|
1223
|
+
};
|
|
1176
1224
|
}, {});
|
|
1177
1225
|
const exportIds = _exports && Object.keys(_exports).map(exportPath => path.join(pkg.name, exportPath));
|
|
1178
1226
|
const sourcePaths = _exports && Object.values(_exports).map(e => path.resolve(cwd, e.source));
|
|
@@ -1182,22 +1230,29 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
1182
1230
|
}));
|
|
1183
1231
|
const defaultPlugins = [replace({
|
|
1184
1232
|
preventAssignment: true,
|
|
1185
|
-
values:
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1233
|
+
values: {
|
|
1234
|
+
...(pkg.name === "@sanity/pkg-utils" ? {
|
|
1235
|
+
...replacements
|
|
1236
|
+
} : {
|
|
1237
|
+
"process.env.PKG_FILE_PATH": arg => {
|
|
1238
|
+
const sourcePath = "./" + path.relative(cwd, arg);
|
|
1239
|
+
const entry = entries.find(e => e.source === sourcePath);
|
|
1240
|
+
if (!entry) {
|
|
1241
|
+
console.error("could not find source entry: ".concat(sourcePath));
|
|
1242
|
+
return "null";
|
|
1243
|
+
}
|
|
1244
|
+
return JSON.stringify(path.relative(cwd, path.resolve(outDir, entry.name + outputExt)));
|
|
1245
|
+
},
|
|
1246
|
+
"process.env.PKG_FORMAT": JSON.stringify(format),
|
|
1247
|
+
"process.env.PKG_RUNTIME": JSON.stringify(runtime),
|
|
1248
|
+
"process.env.PKG_VERSION": JSON.stringify(process.env.PKG_VERSION || pkg.version),
|
|
1249
|
+
...replacements
|
|
1250
|
+
})
|
|
1251
|
+
}
|
|
1199
1252
|
}), alias({
|
|
1200
|
-
entries:
|
|
1253
|
+
entries: {
|
|
1254
|
+
...pathAliases
|
|
1255
|
+
}
|
|
1201
1256
|
}), nodeResolve({
|
|
1202
1257
|
browser: runtime === "browser",
|
|
1203
1258
|
extensions: [".cjs", ".mjs", ".js", ".jsx", ".json", ".node"],
|
|
@@ -1211,7 +1266,7 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
1211
1266
|
tsconfig: ctx.ts.configPath || "tsconfig.json"
|
|
1212
1267
|
}), getBabelOutputPlugin({
|
|
1213
1268
|
babelrc: false,
|
|
1214
|
-
plugins:
|
|
1269
|
+
plugins: (_b = config == null ? void 0 : config.babel) == null ? void 0 : _b.plugins,
|
|
1215
1270
|
presets: [["@babel/preset-env", {
|
|
1216
1271
|
targets: pkg.browserslist || DEFAULT_BROWSERSLIST_QUERY,
|
|
1217
1272
|
modules: false
|
|
@@ -1231,8 +1286,8 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
1231
1286
|
}
|
|
1232
1287
|
}
|
|
1233
1288
|
})].filter(Boolean);
|
|
1234
|
-
const userPlugins = (
|
|
1235
|
-
const plugins = Array.isArray(userPlugins) ? defaultPlugins.concat(userPlugins) : resolveConfigProperty((
|
|
1289
|
+
const userPlugins = (_c = config == null ? void 0 : config.rollup) == null ? void 0 : _c.plugins;
|
|
1290
|
+
const plugins = Array.isArray(userPlugins) ? defaultPlugins.concat(userPlugins) : resolveConfigProperty((_d = config == null ? void 0 : config.rollup) == null ? void 0 : _d.plugins, defaultPlugins);
|
|
1236
1291
|
return {
|
|
1237
1292
|
inputOptions: {
|
|
1238
1293
|
context: cwd,
|
|
@@ -1255,9 +1310,10 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
1255
1310
|
return false;
|
|
1256
1311
|
},
|
|
1257
1312
|
input: entries.reduce((acc, entry) => {
|
|
1258
|
-
return
|
|
1313
|
+
return {
|
|
1314
|
+
...acc,
|
|
1259
1315
|
[entry.name]: entry.source
|
|
1260
|
-
}
|
|
1316
|
+
};
|
|
1261
1317
|
}, {}),
|
|
1262
1318
|
plugins,
|
|
1263
1319
|
treeshake: {
|
|
@@ -1342,7 +1398,8 @@ async function execPromise(ctx, task) {
|
|
|
1342
1398
|
inputOptions,
|
|
1343
1399
|
outputOptions
|
|
1344
1400
|
} = resolveRollupConfig(ctx, task);
|
|
1345
|
-
const bundle = await rollup(
|
|
1401
|
+
const bundle = await rollup({
|
|
1402
|
+
...inputOptions,
|
|
1346
1403
|
onwarn(warning) {
|
|
1347
1404
|
consoleSpy.messages.push({
|
|
1348
1405
|
type: "warn",
|
|
@@ -1350,7 +1407,7 @@ async function execPromise(ctx, task) {
|
|
|
1350
1407
|
args: [warning.message]
|
|
1351
1408
|
});
|
|
1352
1409
|
}
|
|
1353
|
-
})
|
|
1410
|
+
});
|
|
1354
1411
|
const {
|
|
1355
1412
|
output
|
|
1356
1413
|
} = await bundle.generate(outputOptions);
|
|
@@ -1383,9 +1440,10 @@ const rollupWatchTask = {
|
|
|
1383
1440
|
outputOptions
|
|
1384
1441
|
} = resolveRollupConfig(ctx, task);
|
|
1385
1442
|
return new Observable(observer => {
|
|
1386
|
-
const watchOptions =
|
|
1443
|
+
const watchOptions = {
|
|
1444
|
+
...inputOptions,
|
|
1387
1445
|
output: outputOptions
|
|
1388
|
-
}
|
|
1446
|
+
};
|
|
1389
1447
|
const watcher = watch$1(watchOptions);
|
|
1390
1448
|
watcher.on("event", event => {
|
|
1391
1449
|
observer.next(event);
|
|
@@ -1429,7 +1487,8 @@ const rollupWatchTask = {
|
|
|
1429
1487
|
};
|
|
1430
1488
|
const buildTaskHandlers = {
|
|
1431
1489
|
"build:dts": dtsTask,
|
|
1432
|
-
"build:js": rollupTask
|
|
1490
|
+
"build:js": rollupTask,
|
|
1491
|
+
"node:reexport-cjs": nodeReexportCjsTask
|
|
1433
1492
|
};
|
|
1434
1493
|
const watchTaskHandlers = {
|
|
1435
1494
|
"watch:dts": dtsWatchTask,
|
|
@@ -1713,9 +1772,10 @@ function resolveWatchTasks(ctx) {
|
|
|
1713
1772
|
const tasks = [];
|
|
1714
1773
|
const exports = Object.entries(ctx.exports || {}).map(_ref17 => {
|
|
1715
1774
|
let [_path, exp] = _ref17;
|
|
1716
|
-
return
|
|
1717
|
-
_path
|
|
1718
|
-
|
|
1775
|
+
return {
|
|
1776
|
+
_path,
|
|
1777
|
+
...exp
|
|
1778
|
+
};
|
|
1719
1779
|
});
|
|
1720
1780
|
const dtsTask = {
|
|
1721
1781
|
type: "watch:dts",
|