@sanity/pkg-utils 1.7.2 → 1.7.3
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/{__resolveBuildContext-9b0aa9f9.cjs → __resolveBuildContext-56b6b816.cjs} +2 -2
- package/dist/__resolveBuildContext-56b6b816.cjs.map +1 -0
- package/dist/{_build-6e7deb31.cjs → _build-49dd667f.cjs} +20 -17
- package/dist/_build-49dd667f.cjs.map +1 -0
- package/dist/{_buildAction-d8841b41.cjs → _buildAction-b58e3a4b.cjs} +4 -8
- package/dist/{_buildAction-d8841b41.cjs.map → _buildAction-b58e3a4b.cjs.map} +1 -1
- package/dist/{_check-04a1f749.cjs → _check-0871d90f.cjs} +2 -2
- package/dist/{_check-04a1f749.cjs.map → _check-0871d90f.cjs.map} +1 -1
- package/dist/{_checkAction-09426a13.cjs → _checkAction-0510605b.cjs} +3 -3
- package/dist/{_checkAction-09426a13.cjs.map → _checkAction-0510605b.cjs.map} +1 -1
- package/dist/{_index-46cab21c.cjs → _index-e3dda92a.cjs} +53 -56
- package/dist/_index-e3dda92a.cjs.map +1 -0
- package/dist/{_watch-cf9c717f.cjs → _watch-e1c86797.cjs} +21 -18
- package/dist/_watch-e1c86797.cjs.map +1 -0
- package/dist/{_watchAction-5941527f.cjs → _watchAction-cfe36cbc.cjs} +4 -8
- package/dist/{_watchAction-5941527f.cjs.map → _watchAction-cfe36cbc.cjs.map} +1 -1
- package/dist/cli.cjs +4 -4
- package/dist/index.cjs +5 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +87 -80
- package/dist/index.js.map +1 -1
- package/dist/types/src/cli/buildAction.d.ts +4 -0
- package/dist/types/src/cli/buildAction.d.ts.map +1 -0
- package/dist/types/src/cli/checkAction.d.ts +5 -0
- package/dist/types/src/cli/checkAction.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/watchAction.d.ts +4 -0
- package/dist/types/src/cli/watchAction.d.ts.map +1 -0
- package/dist/types/src/node/_core/_defaults.d.ts +5 -0
- package/dist/types/src/node/_core/_defaults.d.ts.map +1 -0
- package/dist/types/src/node/_core/_isRecord.d.ts +3 -0
- package/dist/types/src/node/_core/_isRecord.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/_loadConfig.d.ts +6 -0
- package/dist/types/src/node/_core/config/_loadConfig.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/_resolveConfigProperty.d.ts +4 -0
- package/dist/types/src/node/_core/config/_resolveConfigProperty.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/defineConfig.d.ts +4 -0
- package/dist/types/src/node/_core/config/defineConfig.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/index.d.ts +5 -0
- package/dist/types/src/node/_core/config/index.d.ts.map +1 -0
- package/dist/types/src/node/_core/config/types.d.ts +76 -0
- package/dist/types/src/node/_core/config/types.d.ts.map +1 -0
- package/dist/types/src/node/_core/contexts/buildContext.d.ts +33 -0
- package/dist/types/src/node/_core/contexts/buildContext.d.ts.map +1 -0
- package/dist/types/src/node/_core/contexts/index.d.ts +2 -0
- package/dist/types/src/node/_core/contexts/index.d.ts.map +1 -0
- package/dist/types/src/node/_core/index.d.ts +7 -0
- package/dist/types/src/node/_core/index.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/_loadPkg.d.ts +6 -0
- package/dist/types/src/node/_core/pkg/_loadPkg.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/_loadPkgWithReporting.d.ts +6 -0
- package/dist/types/src/node/_core/pkg/_loadPkgWithReporting.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/_parseExports.d.ts +9 -0
- package/dist/types/src/node/_core/pkg/_parseExports.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/_types.d.ts +29 -0
- package/dist/types/src/node/_core/pkg/_types.d.ts.map +1 -0
- package/dist/types/src/node/_core/pkg/index.d.ts +5 -0
- package/dist/types/src/node/_core/pkg/index.d.ts.map +1 -0
- package/dist/types/src/node/_core/ts/_loadTSConfig.d.ts +7 -0
- package/dist/types/src/node/_core/ts/_loadTSConfig.d.ts.map +1 -0
- package/dist/types/src/node/_core/ts/index.d.ts +2 -0
- package/dist/types/src/node/_core/ts/index.d.ts.map +1 -0
- package/dist/types/src/node/_getFilesize.d.ts +2 -0
- package/dist/types/src/node/_getFilesize.d.ts.map +1 -0
- package/dist/types/src/node/_globFiles.d.ts +2 -0
- package/dist/types/src/node/_globFiles.d.ts.map +1 -0
- package/dist/types/src/node/_printExtractMessages.d.ts +4 -0
- package/dist/types/src/node/_printExtractMessages.d.ts.map +1 -0
- package/dist/types/src/node/_printPackageTree.d.ts +4 -0
- package/dist/types/src/node/_printPackageTree.d.ts.map +1 -0
- package/dist/types/src/node/_resolveBrowserTarget.d.ts +3 -0
- package/dist/types/src/node/_resolveBrowserTarget.d.ts.map +1 -0
- package/dist/types/src/node/_resolveBrowserslistVersions.d.ts +11 -0
- package/dist/types/src/node/_resolveBrowserslistVersions.d.ts.map +1 -0
- package/dist/types/src/node/_resolveBuildContext.d.ts +8 -0
- package/dist/types/src/node/_resolveBuildContext.d.ts.map +1 -0
- package/dist/types/src/node/_resolveBuildTasks.d.ts +5 -0
- package/dist/types/src/node/_resolveBuildTasks.d.ts.map +1 -0
- package/dist/types/src/node/_resolveNodeTarget.d.ts +3 -0
- package/dist/types/src/node/_resolveNodeTarget.d.ts.map +1 -0
- package/dist/types/src/node/_resolveWatchTasks.d.ts +5 -0
- package/dist/types/src/node/_resolveWatchTasks.d.ts.map +1 -0
- package/dist/types/src/node/_spinner.d.ts +5 -0
- package/dist/types/src/node/_spinner.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/_types.d.ts +50 -0
- package/dist/types/src/node/_tasks/_types.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_DtsError.d.ts +7 -0
- package/dist/types/src/node/_tasks/dts/_DtsError.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_buildTypes.d.ts +9 -0
- package/dist/types/src/node/_tasks/dts/_buildTypes.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_createApiExtractorConfig.d.ts +11 -0
- package/dist/types/src/node/_tasks/dts/_createApiExtractorConfig.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_createTSDocConfig.d.ts +12 -0
- package/dist/types/src/node/_tasks/dts/_createTSDocConfig.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_doExtract.d.ts +4 -0
- package/dist/types/src/node/_tasks/dts/_doExtract.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_dtsTask.d.ts +5 -0
- package/dist/types/src/node/_tasks/dts/_dtsTask.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_dtsWatchTask.d.ts +5 -0
- package/dist/types/src/node/_tasks/dts/_dtsWatchTask.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_extractTypes.d.ts +17 -0
- package/dist/types/src/node/_tasks/dts/_extractTypes.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/_types.d.ts +27 -0
- package/dist/types/src/node/_tasks/dts/_types.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/dts/index.d.ts +4 -0
- package/dist/types/src/node/_tasks/dts/index.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/index.d.ts +9 -0
- package/dist/types/src/node/_tasks/index.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/rollup/_resolveRollupConfig.d.ts +10 -0
- package/dist/types/src/node/_tasks/rollup/_resolveRollupConfig.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/rollup/_rollupTask.d.ts +4 -0
- package/dist/types/src/node/_tasks/rollup/_rollupTask.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/rollup/_rollupWatchTask.d.ts +5 -0
- package/dist/types/src/node/_tasks/rollup/_rollupWatchTask.d.ts.map +1 -0
- package/dist/types/src/node/_tasks/rollup/index.d.ts +3 -0
- package/dist/types/src/node/_tasks/rollup/index.d.ts.map +1 -0
- package/dist/types/src/node/_watchConfigFiles.d.ts +5 -0
- package/dist/types/src/node/_watchConfigFiles.d.ts.map +1 -0
- package/dist/types/src/node/_watchFiles.d.ts +7 -0
- package/dist/types/src/node/_watchFiles.d.ts.map +1 -0
- package/dist/types/src/node/build.d.ts +6 -0
- package/dist/types/src/node/build.d.ts.map +1 -0
- package/dist/types/src/node/check.d.ts +7 -0
- package/dist/types/src/node/check.d.ts.map +1 -0
- package/dist/{index.d.ts → types/src/node/index.d.ts} +12 -8
- package/dist/types/src/node/index.d.ts.map +1 -0
- package/dist/types/src/node/watch.d.ts +6 -0
- package/dist/types/src/node/watch.d.ts.map +1 -0
- package/package.json +7 -6
- package/src/node/_core/pkg/_loadPkgWithReporting.ts +1 -1
- package/src/node/_resolveBuildTasks.ts +18 -14
- package/src/node/_resolveWatchTasks.ts +19 -15
- package/src/node/_tasks/dts/_buildTypes.ts +2 -25
- package/src/node/_tasks/dts/_doExtract.ts +32 -31
- package/src/node/_tasks/dts/_dtsTask.ts +4 -1
- package/src/node/_tasks/dts/_dtsWatchTask.ts +4 -1
- package/src/node/_tasks/dts/_types.ts +12 -8
- package/src/node/_tasks/rollup/_resolveRollupConfig.ts +30 -3
- package/dist/__resolveBuildContext-9b0aa9f9.cjs.map +0 -1
- package/dist/_build-6e7deb31.cjs.map +0 -1
- package/dist/_index-46cab21c.cjs.map +0 -1
- package/dist/_watch-cf9c717f.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -20,8 +20,6 @@ import chalk from 'chalk';
|
|
|
20
20
|
import ts from 'typescript';
|
|
21
21
|
import fs$1, { statSync } from 'fs';
|
|
22
22
|
import { Observable, switchMap } from 'rxjs';
|
|
23
|
-
import { promisify } from 'util';
|
|
24
|
-
import rimrafCallback from 'rimraf';
|
|
25
23
|
import { ExtractorConfig, Extractor } from '@microsoft/api-extractor';
|
|
26
24
|
import mkdirp from 'mkdirp';
|
|
27
25
|
import prettier from 'prettier';
|
|
@@ -171,7 +169,7 @@ async function _loadPkgWithReporting(options) {
|
|
|
171
169
|
if (err instanceof ZodError) {
|
|
172
170
|
for (const issue of err.issues) {
|
|
173
171
|
if (issue.code === "invalid_type") {
|
|
174
|
-
console.log("".concat(chalk.red("invalid type"), " in ./package.json at ").concat(chalk.magenta("`".concat(issue.path.join(""), "`")), " (expected ").concat(issue.expected, ", received ").concat(issue.received, ")"));
|
|
172
|
+
console.log("".concat(chalk.red("invalid type"), " in ./package.json at ").concat(chalk.magenta("`".concat(issue.path.join("."), "`")), " (expected ").concat(issue.expected, ", received ").concat(issue.received, ")"));
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
} else {
|
|
@@ -253,13 +251,18 @@ function _resolveBuildTasks(ctx) {
|
|
|
253
251
|
_path
|
|
254
252
|
}, exp);
|
|
255
253
|
});
|
|
256
|
-
const
|
|
254
|
+
const dtsTask = {
|
|
255
|
+
type: "build:dts",
|
|
256
|
+
entries: []
|
|
257
|
+
};
|
|
257
258
|
const rollupTasks = {};
|
|
258
259
|
|
|
259
260
|
function _addRollupTaskEntry(format, runtime, entry) {
|
|
260
261
|
const buildId = "".concat(format, ":").concat(runtime);
|
|
261
262
|
|
|
262
|
-
if (
|
|
263
|
+
if (rollupTasks[buildId]) {
|
|
264
|
+
rollupTasks[buildId].entries.push(entry);
|
|
265
|
+
} else {
|
|
263
266
|
rollupTasks[buildId] = {
|
|
264
267
|
type: "build:js",
|
|
265
268
|
buildId,
|
|
@@ -268,8 +271,6 @@ function _resolveBuildTasks(ctx) {
|
|
|
268
271
|
format,
|
|
269
272
|
target: target[runtime]
|
|
270
273
|
};
|
|
271
|
-
} else {
|
|
272
|
-
rollupTasks[buildId].entries.push(entry);
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
|
|
@@ -277,15 +278,12 @@ function _resolveBuildTasks(ctx) {
|
|
|
277
278
|
const importId = path.join(pkg.name, exp._path);
|
|
278
279
|
|
|
279
280
|
if (exp.types) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
targetPath: exp.types
|
|
287
|
-
};
|
|
288
|
-
}
|
|
281
|
+
dtsTask.entries.push({
|
|
282
|
+
importId,
|
|
283
|
+
exportPath: exp._path,
|
|
284
|
+
sourcePath: exp.source,
|
|
285
|
+
targetPath: exp.types
|
|
286
|
+
});
|
|
289
287
|
}
|
|
290
288
|
}
|
|
291
289
|
|
|
@@ -333,7 +331,10 @@ function _resolveBuildTasks(ctx) {
|
|
|
333
331
|
});
|
|
334
332
|
}
|
|
335
333
|
|
|
336
|
-
|
|
334
|
+
if (dtsTask.entries.length) {
|
|
335
|
+
tasks.push(dtsTask);
|
|
336
|
+
}
|
|
337
|
+
|
|
337
338
|
tasks.push(...Object.values(rollupTasks));
|
|
338
339
|
|
|
339
340
|
for (const exp of exports) {
|
|
@@ -394,9 +395,7 @@ const formatHost = {
|
|
|
394
395
|
|
|
395
396
|
async function _buildTypes(options) {
|
|
396
397
|
const {
|
|
397
|
-
cwd,
|
|
398
398
|
outDir,
|
|
399
|
-
sourcePath,
|
|
400
399
|
tsconfig
|
|
401
400
|
} = options;
|
|
402
401
|
|
|
@@ -408,15 +407,7 @@ async function _buildTypes(options) {
|
|
|
408
407
|
outDir
|
|
409
408
|
});
|
|
410
409
|
|
|
411
|
-
const rootDir = path.relative(cwd, compilerOptions.rootDir ? path.resolve(cwd, compilerOptions.rootDir) : path.dirname(path.resolve(cwd, sourcePath))) || ".";
|
|
412
410
|
const program = ts.createProgram(tsconfig.fileNames, compilerOptions);
|
|
413
|
-
const sourceFiles = program.getSourceFiles();
|
|
414
|
-
const sourceFile = sourceFiles.find(f => f.fileName === path.resolve(cwd, sourcePath));
|
|
415
|
-
|
|
416
|
-
if (!sourceFile) {
|
|
417
|
-
throw new Error("source file not found: ".concat(sourcePath));
|
|
418
|
-
}
|
|
419
|
-
|
|
420
411
|
const emitResult = program.emit();
|
|
421
412
|
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
422
413
|
allDiagnostics.forEach(diagnostic => {
|
|
@@ -440,11 +431,6 @@ async function _buildTypes(options) {
|
|
|
440
431
|
throw new Error("failed to compile");
|
|
441
432
|
}
|
|
442
433
|
}
|
|
443
|
-
|
|
444
|
-
const typesPath = path.resolve(outDir, path.relative(rootDir, path.resolve(cwd, sourcePath))).replace(/\.[jt]sx?$/, ".d.ts");
|
|
445
|
-
return {
|
|
446
|
-
path: typesPath
|
|
447
|
-
};
|
|
448
434
|
}
|
|
449
435
|
|
|
450
436
|
class _DtsError extends Error {
|
|
@@ -628,8 +614,6 @@ async function _extractTypes(options) {
|
|
|
628
614
|
};
|
|
629
615
|
}
|
|
630
616
|
|
|
631
|
-
const rimraf = promisify(rimrafCallback);
|
|
632
|
-
|
|
633
617
|
async function _doExtract(ctx, task) {
|
|
634
618
|
var _a;
|
|
635
619
|
|
|
@@ -644,38 +628,37 @@ async function _doExtract(ctx, task) {
|
|
|
644
628
|
type: "dts",
|
|
645
629
|
messages: []
|
|
646
630
|
};
|
|
647
|
-
const sourcePath = task.sourcePath;
|
|
648
|
-
const exportPath = task.exportPath === "." ? "./index" : task.exportPath;
|
|
649
631
|
const distPath = path.resolve(cwd, dist);
|
|
650
|
-
const filePath = path.relative(distPath, path.resolve(cwd, task.targetPath));
|
|
651
|
-
const tmpDirPath = path.resolve(distPath, "__dts__");
|
|
652
|
-
const tmpDir = {
|
|
653
|
-
path: tmpDirPath,
|
|
654
|
-
removeCallback: () => rimraf(tmpDirPath)
|
|
655
|
-
};
|
|
656
|
-
const types = await _buildTypes({
|
|
657
|
-
cwd,
|
|
658
|
-
outDir: tmpDir.path,
|
|
659
|
-
sourcePath,
|
|
660
|
-
tsconfig: ts.config
|
|
661
|
-
});
|
|
662
632
|
const {
|
|
663
|
-
|
|
664
|
-
|
|
633
|
+
outDir = distPath,
|
|
634
|
+
rootDir = cwd
|
|
635
|
+
} = ts.config.options;
|
|
636
|
+
await _buildTypes({
|
|
665
637
|
cwd,
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
filePath,
|
|
669
|
-
projectPath: cwd,
|
|
670
|
-
rules: (_a = config == null ? void 0 : config.extract) == null ? void 0 : _a.rules,
|
|
671
|
-
sourcePath: types.path,
|
|
672
|
-
tsconfigPath: path.resolve(cwd, ts.configPath),
|
|
673
|
-
distPath
|
|
638
|
+
outDir,
|
|
639
|
+
tsconfig: ts.config
|
|
674
640
|
});
|
|
675
|
-
|
|
641
|
+
const messages = [];
|
|
642
|
+
|
|
643
|
+
for (const entry of task.entries) {
|
|
644
|
+
const exportPath = entry.exportPath === "." ? "./index" : entry.exportPath;
|
|
645
|
+
const filePath = path.relative(distPath, path.resolve(cwd, entry.targetPath));
|
|
646
|
+
const result = await _extractTypes({
|
|
647
|
+
cwd,
|
|
648
|
+
exportPath,
|
|
649
|
+
files,
|
|
650
|
+
filePath,
|
|
651
|
+
projectPath: cwd,
|
|
652
|
+
rules: (_a = config == null ? void 0 : config.extract) == null ? void 0 : _a.rules,
|
|
653
|
+
sourcePath: path.resolve(outDir, path.relative(cwd, rootDir), entry.sourcePath.replace(/\.ts$/, ".d.ts")),
|
|
654
|
+
tsconfigPath: path.resolve(cwd, ts.configPath),
|
|
655
|
+
distPath
|
|
656
|
+
});
|
|
657
|
+
messages.push(...result.messages);
|
|
676
658
|
|
|
677
|
-
|
|
678
|
-
|
|
659
|
+
if (result.messages.some(msg => msg.logLevel === "error")) {
|
|
660
|
+
throw new _DtsError("encountered errors when extracting types", result.messages);
|
|
661
|
+
}
|
|
679
662
|
}
|
|
680
663
|
|
|
681
664
|
return {
|
|
@@ -685,7 +668,7 @@ async function _doExtract(ctx, task) {
|
|
|
685
668
|
}
|
|
686
669
|
|
|
687
670
|
const _dtsTask = {
|
|
688
|
-
name: (_ctx, task) => ["build type definitions", " ".concat(chalk.blue(
|
|
671
|
+
name: (_ctx, task) => ["build type definitions", ...task.entries.map(entry => " ".concat(chalk.blue(entry.importId), ": ").concat(entry.sourcePath, " -> ").concat(entry.targetPath))].join("\n"),
|
|
689
672
|
exec: (ctx, task) => {
|
|
690
673
|
return new Observable(observer => {
|
|
691
674
|
_doExtract(ctx, task).then(result => {
|
|
@@ -712,7 +695,7 @@ const _dtsTask = {
|
|
|
712
695
|
}
|
|
713
696
|
};
|
|
714
697
|
const _dtsWatchTask = {
|
|
715
|
-
name: (_ctx, task) => ["build type definitions", " ".concat(chalk.blue(
|
|
698
|
+
name: (_ctx, task) => ["build type definitions", ...task.entries.map(entry => " ".concat(chalk.blue(entry.importId), ": ").concat(entry.sourcePath, " -> ").concat(entry.targetPath))].join("\n"),
|
|
716
699
|
exec: (ctx, task) => {
|
|
717
700
|
return new Observable(observer => {
|
|
718
701
|
_doExtract(ctx, task).then(result => {
|
|
@@ -757,12 +740,14 @@ function _resolveRollupConfig(ctx, buildTask) {
|
|
|
757
740
|
const {
|
|
758
741
|
config,
|
|
759
742
|
cwd,
|
|
743
|
+
exports: _exports,
|
|
760
744
|
external,
|
|
761
745
|
dist: outDir,
|
|
746
|
+
logger,
|
|
762
747
|
pkg,
|
|
763
748
|
ts
|
|
764
749
|
} = ctx;
|
|
765
|
-
const outputExt = format === "commonjs" ? ".cjs" :
|
|
750
|
+
const outputExt = format === "commonjs" ? ".cjs" : ".js";
|
|
766
751
|
const minify = (_ref2 = config == null ? void 0 : config.minify) !== null && _ref2 !== void 0 ? _ref2 : true;
|
|
767
752
|
const pathAliases = Object.fromEntries(Object.entries(((_a = ts.config) == null ? void 0 : _a.options.paths) || {}).map(_ref3 => {
|
|
768
753
|
let [key, val] = _ref3;
|
|
@@ -776,10 +761,28 @@ function _resolveRollupConfig(ctx, buildTask) {
|
|
|
776
761
|
name: path.relative(outDir, entry.output).replace(/\.[^/.]+$/, "")
|
|
777
762
|
});
|
|
778
763
|
}, {});
|
|
764
|
+
|
|
765
|
+
const exportIds = _exports && Object.keys(_exports).map(exportPath => path.join(pkg.name, exportPath));
|
|
766
|
+
|
|
767
|
+
const sourcePaths = _exports && Object.values(_exports).map(e => path.resolve(cwd, e.source));
|
|
768
|
+
|
|
779
769
|
return {
|
|
780
770
|
inputOptions: {
|
|
781
771
|
context: cwd,
|
|
782
|
-
external: id => {
|
|
772
|
+
external: (id, importer) => {
|
|
773
|
+
if (exportIds == null ? void 0 : exportIds.includes(id)) {
|
|
774
|
+
return true;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
if (importer && (id.startsWith(".") || id.startsWith("/"))) {
|
|
778
|
+
const idPath = path.resolve(path.dirname(importer), id);
|
|
779
|
+
|
|
780
|
+
if (sourcePaths == null ? void 0 : sourcePaths.includes(idPath)) {
|
|
781
|
+
logger.warn("detected self-referencing import \u2013 treating as external: ".concat(path.relative(cwd, idPath)));
|
|
782
|
+
return true;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
783
786
|
const idParts = id.split("/");
|
|
784
787
|
const name = idParts[0].startsWith("@") ? "".concat(idParts[0], "/").concat(idParts[1]) : idParts[0];
|
|
785
788
|
|
|
@@ -835,6 +838,7 @@ function _resolveRollupConfig(ctx, buildTask) {
|
|
|
835
838
|
target,
|
|
836
839
|
tsconfig: ctx.ts.configPath || "tsconfig.json"
|
|
837
840
|
}), getBabelOutputPlugin({
|
|
841
|
+
babelrc: false,
|
|
838
842
|
plugins: ["@babel/plugin-proposal-object-rest-spread"],
|
|
839
843
|
presets: [["@babel/preset-env", {
|
|
840
844
|
targets: pkg.browserslist || _DEFAULTS.browserslist
|
|
@@ -1466,13 +1470,18 @@ function _resolveWatchTasks(ctx) {
|
|
|
1466
1470
|
_path
|
|
1467
1471
|
}, exp);
|
|
1468
1472
|
});
|
|
1469
|
-
const
|
|
1473
|
+
const dtsTask = {
|
|
1474
|
+
type: "watch:dts",
|
|
1475
|
+
entries: []
|
|
1476
|
+
};
|
|
1470
1477
|
const rollupTasks = {};
|
|
1471
1478
|
|
|
1472
1479
|
function _addRollupTaskEntry(format, runtime, entry) {
|
|
1473
1480
|
const buildId = "".concat(format, ":").concat(runtime);
|
|
1474
1481
|
|
|
1475
|
-
if (
|
|
1482
|
+
if (rollupTasks[buildId]) {
|
|
1483
|
+
rollupTasks[buildId].entries.push(entry);
|
|
1484
|
+
} else {
|
|
1476
1485
|
rollupTasks[buildId] = {
|
|
1477
1486
|
type: "watch:js",
|
|
1478
1487
|
buildId,
|
|
@@ -1481,8 +1490,6 @@ function _resolveWatchTasks(ctx) {
|
|
|
1481
1490
|
format,
|
|
1482
1491
|
target: target[runtime]
|
|
1483
1492
|
};
|
|
1484
|
-
} else {
|
|
1485
|
-
rollupTasks[buildId].entries.push(entry);
|
|
1486
1493
|
}
|
|
1487
1494
|
}
|
|
1488
1495
|
|
|
@@ -1490,15 +1497,12 @@ function _resolveWatchTasks(ctx) {
|
|
|
1490
1497
|
const importId = path.join(pkg.name, exp._path);
|
|
1491
1498
|
|
|
1492
1499
|
if (exp.types) {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
targetPath: exp.types
|
|
1500
|
-
};
|
|
1501
|
-
}
|
|
1500
|
+
dtsTask.entries.push({
|
|
1501
|
+
importId,
|
|
1502
|
+
exportPath: exp._path,
|
|
1503
|
+
sourcePath: exp.source,
|
|
1504
|
+
targetPath: exp.types
|
|
1505
|
+
});
|
|
1502
1506
|
}
|
|
1503
1507
|
}
|
|
1504
1508
|
|
|
@@ -1546,7 +1550,10 @@ function _resolveWatchTasks(ctx) {
|
|
|
1546
1550
|
});
|
|
1547
1551
|
}
|
|
1548
1552
|
|
|
1549
|
-
|
|
1553
|
+
if (dtsTask.entries.length) {
|
|
1554
|
+
tasks.push(dtsTask);
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1550
1557
|
tasks.push(...Object.values(rollupTasks));
|
|
1551
1558
|
|
|
1552
1559
|
for (const exp of exports) {
|
|
@@ -1554,7 +1561,7 @@ function _resolveWatchTasks(ctx) {
|
|
|
1554
1561
|
const relativeTargetPath = (((_e = exp.browser) == null ? void 0 : _e.import) || exp.import || "").replace(/\.[^/.]+$/, "");
|
|
1555
1562
|
|
|
1556
1563
|
if (relativeTargetPath) {
|
|
1557
|
-
fs$1.writeFileSync(path.resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export
|
|
1564
|
+
fs$1.writeFileSync(path.resolve(cwd, "".concat(exp._path, ".js")), ["// AUTO-GENERATED \u2013 DO NOT EDIT", "", "export * from '".concat(relativeTargetPath, "'"), ""].join("\n"));
|
|
1558
1565
|
}
|
|
1559
1566
|
}
|
|
1560
1567
|
}
|