@xylabs/ts-scripts-yarn3 3.1.3 → 3.1.4

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.
Files changed (45) hide show
  1. package/dist/actions/package/compile/CompileParams.js.map +1 -1
  2. package/dist/actions/package/compile/compile.js +15 -48
  3. package/dist/actions/package/compile/compile.js.map +1 -1
  4. package/dist/actions/package/compile/compile.mjs +15 -48
  5. package/dist/actions/package/compile/compile.mjs.map +1 -1
  6. package/dist/actions/package/compile/index.js +4 -6
  7. package/dist/actions/package/compile/index.js.map +1 -1
  8. package/dist/actions/package/compile/index.mjs +2 -3
  9. package/dist/actions/package/compile/index.mjs.map +1 -1
  10. package/dist/actions/package/compile/{tscNoEmit.js → packageCompileTsc.js} +10 -16
  11. package/dist/actions/package/compile/packageCompileTsc.js.map +1 -0
  12. package/dist/actions/package/compile/{tscNoEmit.mjs → packageCompileTsc.mjs} +6 -12
  13. package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -0
  14. package/dist/actions/package/compile/{tsup2.js → packageCompileTsup.js} +9 -9
  15. package/dist/actions/package/compile/packageCompileTsup.js.map +1 -0
  16. package/dist/actions/package/compile/{tsup2.mjs → packageCompileTsup.mjs} +5 -5
  17. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -0
  18. package/dist/index.d.mts +7 -22
  19. package/dist/index.d.ts +7 -22
  20. package/package.json +4 -4
  21. package/src/actions/package/compile/CompileParams.ts +3 -0
  22. package/src/actions/package/compile/compile.ts +14 -58
  23. package/src/actions/package/compile/index.ts +2 -3
  24. package/src/actions/package/compile/{tscNoEmit.ts → packageCompileTsc.ts} +2 -8
  25. package/src/actions/package/compile/{tsup2.ts → packageCompileTsup.ts} +4 -4
  26. package/xy.config.ts +8 -0
  27. package/dist/actions/package/compile/rollup.js +0 -135
  28. package/dist/actions/package/compile/rollup.js.map +0 -1
  29. package/dist/actions/package/compile/rollup.mjs +0 -100
  30. package/dist/actions/package/compile/rollup.mjs.map +0 -1
  31. package/dist/actions/package/compile/tsc.js +0 -90
  32. package/dist/actions/package/compile/tsc.js.map +0 -1
  33. package/dist/actions/package/compile/tsc.mjs +0 -64
  34. package/dist/actions/package/compile/tsc.mjs.map +0 -1
  35. package/dist/actions/package/compile/tscNoEmit.js.map +0 -1
  36. package/dist/actions/package/compile/tscNoEmit.mjs.map +0 -1
  37. package/dist/actions/package/compile/tsup.js +0 -87
  38. package/dist/actions/package/compile/tsup.js.map +0 -1
  39. package/dist/actions/package/compile/tsup.mjs +0 -63
  40. package/dist/actions/package/compile/tsup.mjs.map +0 -1
  41. package/dist/actions/package/compile/tsup2.js.map +0 -1
  42. package/dist/actions/package/compile/tsup2.mjs.map +0 -1
  43. package/src/actions/package/compile/rollup.ts +0 -109
  44. package/src/actions/package/compile/tsc.ts +0 -84
  45. package/src/actions/package/compile/tsup.ts +0 -86
@@ -4,6 +4,8 @@ export interface RootParams {
4
4
 
5
5
  export type EntryMode = 'all' | 'single' | 'auto' | 'platform'
6
6
 
7
+ export type CompileMode = 'tsup' | 'tsc'
8
+
7
9
  export interface CompileParams extends RootParams {
8
10
  compile?: {
9
11
  depth?: number
@@ -11,6 +13,7 @@ export interface CompileParams extends RootParams {
11
13
  entryMode?: EntryMode
12
14
  /** @param files Manually specify the files to be compiled */
13
15
  files?: string[]
16
+ mode?: CompileMode
14
17
  publint?: boolean
15
18
  }
16
19
  }
@@ -1,72 +1,28 @@
1
1
  import chalk from 'chalk'
2
- // eslint-disable-next-line import/no-internal-modules
3
- import merge from 'lodash/merge'
4
2
 
5
3
  import { loadConfig } from '../../../lib'
6
4
  import { packagePublint } from '../publint'
7
5
  import { CompileParams } from './CompileParams'
8
- import { packageCompileRollup } from './rollup'
9
- import { packageCompileTsc } from './tsc'
10
- import { packageCompileTsup2 } from './tsup2'
6
+ import { packageCompileTsc } from './packageCompileTsc'
7
+ import { packageCompileTsup } from './packageCompileTsup'
11
8
 
12
- export type PackageCompileMode = 'tsup' | 'tsc' | 'rollup'
13
-
14
- export type PackageCompileParams = CompileParams & {
15
- compile?: {
16
- modes?: PackageCompileMode[]
17
- }
18
- }
19
-
20
- export const packageCompile = async (
21
- params: PackageCompileParams = {
22
- compile: {
23
- publint: false,
24
- },
25
- },
26
- ): Promise<number> => {
9
+ export const packageCompile = async (params: CompileParams = {}): Promise<number> => {
27
10
  const pkg = process.env.INIT_CWD
28
11
  console.log(chalk.green(`Compiling ${pkg}`))
29
12
  const config = await loadConfig(params)
30
- const publint = false //config.compile?.publint ?? false
13
+ const publint = config.compile?.publint ?? false
31
14
 
32
- const modes = config.compile?.modes ?? ['tsup']
33
- let modeIndex = 0
15
+ const mode = config.compile?.mode ?? 'tsup'
34
16
  let result: number = 0
35
- while (modeIndex < modes.length) {
36
- const mode = modes[modeIndex]
37
- switch (mode) {
38
- case 'rollup': {
39
- result += await packageCompileRollup(
40
- merge({}, params, {
41
- compile: {
42
- publint: false,
43
- },
44
- }),
45
- )
46
- break
47
- }
48
- case 'tsc': {
49
- result += await packageCompileTsc(
50
- merge({}, params, {
51
- compile: {
52
- publint: false,
53
- },
54
- }),
55
- )
56
- break
57
- }
58
- case 'tsup': {
59
- result += await packageCompileTsup2(
60
- merge({}, params, {
61
- compile: {
62
- publint: false,
63
- },
64
- }),
65
- )
66
- break
67
- }
17
+ switch (mode) {
18
+ case 'tsc': {
19
+ result += packageCompileTsc(undefined, config)
20
+ break
21
+ }
22
+ case 'tsup': {
23
+ result += await packageCompileTsup(config)
24
+ break
68
25
  }
69
- modeIndex++
70
26
  }
71
- return result + (publint ? await packagePublint(params) : 0)
27
+ return result + (publint ? await packagePublint(config) : 0)
72
28
  }
@@ -1,4 +1,3 @@
1
1
  export * from './compile'
2
- export * from './rollup'
3
- export * from './tsc'
4
- export * from './tsup'
2
+ export * from './packageCompileTsc'
3
+ export * from './packageCompileTsup'
@@ -14,7 +14,7 @@ import {
14
14
  import { CompileParams } from './CompileParams'
15
15
  import { getCompilerOptions } from './getCompilerOptions'
16
16
 
17
- export const packageCompileTscNoEmit = (params?: CompileParams, compilerOptionsParam?: CompilerOptions): number => {
17
+ export const packageCompileTsc = (noEmit?: boolean, params?: CompileParams, compilerOptionsParam?: CompilerOptions): number => {
18
18
  const pkg = process.env.INIT_CWD ?? cwd()
19
19
 
20
20
  const formatHost: FormatDiagnosticsHost = {
@@ -29,17 +29,11 @@ export const packageCompileTscNoEmit = (params?: CompileParams, compilerOptionsP
29
29
 
30
30
  const compilerOptions = {
31
31
  ...getCompilerOptions({
32
- declaration: true,
33
- declarationMap: true,
34
- emitDeclarationOnly: true,
35
- esModuleInterop: true,
36
32
  outDir: 'dist',
37
33
  rootDir: 'src',
38
- skipDefaultLibCheck: true,
39
- skipLibCheck: true,
40
- sourceMap: true,
41
34
  }),
42
35
  ...(compilerOptionsParam ?? {}),
36
+ ...(noEmit !== undefined ? { noEmit } : {}),
43
37
  } as TsConfigCompilerOptions
44
38
 
45
39
  const program = createProgramFromConfig({
@@ -4,10 +4,10 @@ import { loadConfig } from '../../../lib'
4
4
  import { packagePublint } from '../publint'
5
5
  import { buildEntries } from './buildEntries'
6
6
  import { CompileParams, EntryMode } from './CompileParams'
7
- import { packageCompileTscNoEmit } from './tscNoEmit'
7
+ import { packageCompileTsc } from './packageCompileTsc'
8
8
  import { packageCompileTscTypes } from './tscTypes'
9
9
 
10
- export type PackageCompileTsup2Params = Partial<
10
+ export type PackageCompileTsupParams = Partial<
11
11
  CompileParams & {
12
12
  compile?: {
13
13
  browser?: Record<string, Options | boolean>
@@ -53,7 +53,7 @@ const compileFolder = async (folder: string, entryMode: EntryMode = 'single', op
53
53
  return 0
54
54
  }
55
55
 
56
- export const packageCompileTsup2 = async (params?: PackageCompileTsup2Params) => {
56
+ export const packageCompileTsup = async (params?: PackageCompileTsupParams) => {
57
57
  const { verbose, compile } = await loadConfig(params)
58
58
  const publint = compile?.publint ?? true
59
59
  if (verbose) {
@@ -64,7 +64,7 @@ export const packageCompileTsup2 = async (params?: PackageCompileTsup2Params) =>
64
64
  const compileForBrowser = compile?.browser ?? { src: {} }
65
65
 
66
66
  return (
67
- packageCompileTscNoEmit({ verbose }) ||
67
+ packageCompileTsc(true, { verbose }) ||
68
68
  (
69
69
  await Promise.all(
70
70
  Object.entries(compileForNode).map(async ([folder, options]) => {
package/xy.config.ts ADDED
@@ -0,0 +1,8 @@
1
+ const config = {
2
+ compile: {
3
+ browser: false,
4
+ },
5
+ }
6
+
7
+ // eslint-disable-next-line import/no-default-export
8
+ export default config
@@ -1,135 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var rollup_exports = {};
30
- __export(rollup_exports, {
31
- compileSubDir: () => compileSubDir,
32
- packageCompileRollup: () => packageCompileRollup
33
- });
34
- module.exports = __toCommonJS(rollup_exports);
35
- var import_plugin_commonjs = __toESM(require("@rollup/plugin-commonjs"));
36
- var import_plugin_json = __toESM(require("@rollup/plugin-json"));
37
- var import_plugin_typescript = __toESM(require("@rollup/plugin-typescript"));
38
- var import_chalk = __toESM(require("chalk"));
39
- var import_rollup = require("rollup");
40
- var import_rollup_plugin_exclude_dependencies_from_bundle = __toESM(require("rollup-plugin-exclude-dependencies-from-bundle"));
41
- var import_rollup_plugin_node_externals = __toESM(require("rollup-plugin-node-externals"));
42
- var import_lib = require("../../../lib");
43
- var import_loadPackageConfig = require("../../../loadPackageConfig");
44
- var import_publint = require("../publint");
45
- var import_inputs = require("./inputs");
46
- const compileSubDir = async (format, ext, subDir, _verbose = false) => {
47
- const dir = subDir === "." ? void 0 : subDir;
48
- const input = await (0, import_inputs.getInputs)(dir);
49
- const tsPlugIn = (0, import_plugin_typescript.default)({
50
- baseUrl: "src",
51
- declaration: !dir || !subDir,
52
- declarationMap: !dir || !subDir,
53
- emitDeclarationOnly: false,
54
- esModuleInterop: true,
55
- exclude: ["**/*.spec.*", "dist", "docs", "node_modules", "packages"],
56
- outDir: dir ? `dist/${dir}` : "dist",
57
- rootDir: "src",
58
- tsconfig: "tsconfig.json"
59
- });
60
- const errors = [];
61
- const warnings = [];
62
- const infos = [];
63
- const debugs = [];
64
- const options = {
65
- input: subDir ? input.map((file) => `./src/${file}`) : ["./src/index.ts"],
66
- logLevel: "warn",
67
- onLog: (level, log, defaultHandler) => {
68
- var _a;
69
- const pushLog = !(log.code === "EMPTY_BUNDLE" || log.code === "MIXED_EXPORTS" || log.code === "UNUSED_EXTERNAL_IMPORT");
70
- if (pushLog) {
71
- switch (level) {
72
- case "warn": {
73
- warnings.push(log);
74
- break;
75
- }
76
- case "info": {
77
- infos.push(log);
78
- break;
79
- }
80
- case "debug": {
81
- debugs.push(log);
82
- break;
83
- }
84
- default: {
85
- errors.push(log);
86
- break;
87
- }
88
- }
89
- }
90
- console.log(import_chalk.default.yellow(`${level}: ${log.message} [${log.code}]`));
91
- if (log.id) {
92
- console.log(import_chalk.default.gray(log.id));
93
- }
94
- (_a = log.ids) == null ? void 0 : _a.map((id) => {
95
- console.log(import_chalk.default.gray(id));
96
- });
97
- return defaultHandler(level, log);
98
- },
99
- plugins: [(0, import_plugin_commonjs.default)(), (0, import_rollup_plugin_exclude_dependencies_from_bundle.default)(), (0, import_rollup_plugin_node_externals.default)(), (0, import_plugin_json.default)(), tsPlugIn]
100
- };
101
- const outputOptions = {
102
- dir: subDir ? `dist/${subDir}` : "dist",
103
- dynamicImportInCjs: true,
104
- entryFileNames: (chunkInfo) => `${chunkInfo.name}.${ext}`,
105
- format,
106
- sourcemap: true
107
- };
108
- if (input.length) {
109
- await (await (0, import_rollup.rollup)(options)).write(outputOptions);
110
- }
111
- return errors.length + warnings.length;
112
- };
113
- const packageCompileRollup = async (params) => {
114
- var _a, _b;
115
- const config = await (0, import_lib.loadConfig)(params);
116
- const pkg = await (0, import_loadPackageConfig.loadPackageConfig)();
117
- const inputDirs = await (0, import_inputs.getInputDirs)((_a = config.compile) == null ? void 0 : _a.depth);
118
- const verbose = config.verbose;
119
- const publint = (_b = config.compile) == null ? void 0 : _b.publint;
120
- const pkgType = pkg.type ?? "commonjs";
121
- const esmExt = pkgType === "module" ? "js" : "mjs";
122
- const cjsExt = pkgType === "commonjs" ? "js" : "cjs";
123
- const result = (await Promise.all(
124
- inputDirs.map(async (inputDir) => {
125
- return await compileSubDir("cjs", cjsExt, inputDir, verbose) + await compileSubDir("esm", esmExt, inputDir, verbose);
126
- })
127
- )).reduce((prev, result2) => prev + result2, 0);
128
- return result + (publint ? await (0, import_publint.packagePublint)() : 0);
129
- };
130
- // Annotate the CommonJS export names for ESM import in node:
131
- 0 && (module.exports = {
132
- compileSubDir,
133
- packageCompileRollup
134
- });
135
- //# sourceMappingURL=rollup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/rollup.ts"],"sourcesContent":["import commonjs from '@rollup/plugin-commonjs'\nimport json from '@rollup/plugin-json'\nimport typescript from '@rollup/plugin-typescript'\nimport chalk from 'chalk'\nimport { OutputOptions, rollup, RollupLog, RollupOptions } from 'rollup'\nimport externalDeps from 'rollup-plugin-exclude-dependencies-from-bundle'\nimport nodeExternals from 'rollup-plugin-node-externals'\n\nimport { loadConfig } from '../../../lib'\nimport { loadPackageConfig } from '../../../loadPackageConfig'\nimport { packagePublint } from '../publint'\nimport { CompileParams } from './CompileParams'\nimport { getInputDirs, getInputs } from './inputs'\n\nexport interface PackageCompileRollupParams extends CompileParams {}\n\nexport const compileSubDir = async (format: 'cjs' | 'esm', ext: string, subDir?: string, _verbose = false) => {\n const dir = subDir === '.' ? undefined : subDir\n const input = await getInputs(dir)\n const tsPlugIn = typescript({\n baseUrl: 'src',\n declaration: !dir || !subDir,\n declarationMap: !dir || !subDir,\n emitDeclarationOnly: false,\n esModuleInterop: true,\n exclude: ['**/*.spec.*', 'dist', 'docs', 'node_modules', 'packages'],\n outDir: dir ? `dist/${dir}` : 'dist',\n rootDir: 'src',\n tsconfig: 'tsconfig.json',\n })\n\n const errors: RollupLog[] = []\n const warnings: RollupLog[] = []\n const infos: RollupLog[] = []\n const debugs: RollupLog[] = []\n\n const options: RollupOptions = {\n input: subDir ? input.map((file) => `./src/${file}`) : ['./src/index.ts'],\n logLevel: 'warn',\n onLog: (level, log, defaultHandler) => {\n const pushLog = !(log.code === 'EMPTY_BUNDLE' || log.code === 'MIXED_EXPORTS' || log.code === 'UNUSED_EXTERNAL_IMPORT')\n if (pushLog) {\n switch (level) {\n case 'warn': {\n warnings.push(log)\n break\n }\n case 'info': {\n infos.push(log)\n break\n }\n case 'debug': {\n debugs.push(log)\n break\n }\n default: {\n errors.push(log)\n break\n }\n }\n }\n console.log(chalk.yellow(`${level}: ${log.message} [${log.code}]`))\n if (log.id) {\n console.log(chalk.gray(log.id))\n }\n log.ids?.map((id) => {\n console.log(chalk.gray(id))\n })\n return defaultHandler(level, log)\n },\n plugins: [commonjs(), externalDeps(), nodeExternals(), json(), tsPlugIn],\n }\n\n const outputOptions: OutputOptions = {\n dir: subDir ? `dist/${subDir}` : 'dist',\n dynamicImportInCjs: true,\n entryFileNames: (chunkInfo) => `${chunkInfo.name}.${ext}`,\n format,\n sourcemap: true,\n }\n\n if (input.length) {\n await (await rollup(options)).write(outputOptions)\n }\n\n return errors.length + warnings.length\n}\n\nexport const packageCompileRollup = async (params?: PackageCompileRollupParams) => {\n const config = await loadConfig(params)\n const pkg = await loadPackageConfig()\n const inputDirs = await getInputDirs(config.compile?.depth)\n const verbose = config.verbose\n const publint = config.compile?.publint\n\n const pkgType = pkg.type ?? 'commonjs'\n\n const esmExt = pkgType === 'module' ? 'js' : 'mjs'\n const cjsExt = pkgType === 'commonjs' ? 'js' : 'cjs'\n\n const result = (\n await Promise.all(\n inputDirs.map(async (inputDir) => {\n return (await compileSubDir('cjs', cjsExt, inputDir, verbose)) + (await compileSubDir('esm', esmExt, inputDir, verbose))\n }),\n )\n ).reduce((prev, result) => prev + result, 0)\n return result + (publint ? await packagePublint() : 0)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAqB;AACrB,yBAAiB;AACjB,+BAAuB;AACvB,mBAAkB;AAClB,oBAAgE;AAChE,4DAAyB;AACzB,0CAA0B;AAE1B,iBAA2B;AAC3B,+BAAkC;AAClC,qBAA+B;AAE/B,oBAAwC;AAIjC,MAAM,gBAAgB,OAAO,QAAuB,KAAa,QAAiB,WAAW,UAAU;AAC5G,QAAM,MAAM,WAAW,MAAM,SAAY;AACzC,QAAM,QAAQ,UAAM,yBAAU,GAAG;AACjC,QAAM,eAAW,yBAAAA,SAAW;AAAA,IAC1B,SAAS;AAAA,IACT,aAAa,CAAC,OAAO,CAAC;AAAA,IACtB,gBAAgB,CAAC,OAAO,CAAC;AAAA,IACzB,qBAAqB;AAAA,IACrB,iBAAiB;AAAA,IACjB,SAAS,CAAC,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AC,SAAK,GAAG,QAAQ;AAAA,EACzE;AAEA,QAAM,gBAA+B;AAAA,IACnC,KAAK,SAAS,QAAQ,MAAM,KAAK;AAAA,IACjC,oBAAoB;AAAA,IACpB,gBAAgB,CAAC,cAAc,GAAG,UAAU,IAAI,IAAI,GAAG;AAAA,IACvD;AAAA,IACA,WAAW;AAAA,EACb;AAEA,MAAI,MAAM,QAAQ;AAChB,WAAO,UAAM,sBAAO,OAAO,GAAG,MAAM,aAAa;AAAA,EACnD;AAEA,SAAO,OAAO,SAAS,SAAS;AAClC;AAEO,MAAM,uBAAuB,OAAO,WAAwC;AAxFnF;AAyFE,QAAM,SAAS,UAAM,uBAAW,MAAM;AACtC,QAAM,MAAM,UAAM,4CAAkB;AACpC,QAAM,YAAY,UAAM,6BAAa,YAAO,YAAP,mBAAgB,KAAK;AAC1D,QAAM,UAAU,OAAO;AACvB,QAAM,WAAU,YAAO,YAAP,mBAAgB;AAEhC,QAAM,UAAU,IAAI,QAAQ;AAE5B,QAAM,SAAS,YAAY,WAAW,OAAO;AAC7C,QAAM,SAAS,YAAY,aAAa,OAAO;AAE/C,QAAM,UACJ,MAAM,QAAQ;AAAA,IACZ,UAAU,IAAI,OAAO,aAAa;AAChC,aAAQ,MAAM,cAAc,OAAO,QAAQ,UAAU,OAAO,IAAM,MAAM,cAAc,OAAO,QAAQ,UAAU,OAAO;AAAA,IACxH,CAAC;AAAA,EACH,GACA,OAAO,CAAC,MAAMC,YAAW,OAAOA,SAAQ,CAAC;AAC3C,SAAO,UAAU,UAAU,UAAM,+BAAe,IAAI;AACtD;","names":["typescript","chalk","commonjs","externalDeps","nodeExternals","json","result"]}
@@ -1,100 +0,0 @@
1
- import commonjs from "@rollup/plugin-commonjs";
2
- import json from "@rollup/plugin-json";
3
- import typescript from "@rollup/plugin-typescript";
4
- import chalk from "chalk";
5
- import { rollup } from "rollup";
6
- import externalDeps from "rollup-plugin-exclude-dependencies-from-bundle";
7
- import nodeExternals from "rollup-plugin-node-externals";
8
- import { loadConfig } from "../../../lib";
9
- import { loadPackageConfig } from "../../../loadPackageConfig";
10
- import { packagePublint } from "../publint";
11
- import { getInputDirs, getInputs } from "./inputs";
12
- const compileSubDir = async (format, ext, subDir, _verbose = false) => {
13
- const dir = subDir === "." ? void 0 : subDir;
14
- const input = await getInputs(dir);
15
- const tsPlugIn = typescript({
16
- baseUrl: "src",
17
- declaration: !dir || !subDir,
18
- declarationMap: !dir || !subDir,
19
- emitDeclarationOnly: false,
20
- esModuleInterop: true,
21
- exclude: ["**/*.spec.*", "dist", "docs", "node_modules", "packages"],
22
- outDir: dir ? `dist/${dir}` : "dist",
23
- rootDir: "src",
24
- tsconfig: "tsconfig.json"
25
- });
26
- const errors = [];
27
- const warnings = [];
28
- const infos = [];
29
- const debugs = [];
30
- const options = {
31
- input: subDir ? input.map((file) => `./src/${file}`) : ["./src/index.ts"],
32
- logLevel: "warn",
33
- onLog: (level, log, defaultHandler) => {
34
- var _a;
35
- const pushLog = !(log.code === "EMPTY_BUNDLE" || log.code === "MIXED_EXPORTS" || log.code === "UNUSED_EXTERNAL_IMPORT");
36
- if (pushLog) {
37
- switch (level) {
38
- case "warn": {
39
- warnings.push(log);
40
- break;
41
- }
42
- case "info": {
43
- infos.push(log);
44
- break;
45
- }
46
- case "debug": {
47
- debugs.push(log);
48
- break;
49
- }
50
- default: {
51
- errors.push(log);
52
- break;
53
- }
54
- }
55
- }
56
- console.log(chalk.yellow(`${level}: ${log.message} [${log.code}]`));
57
- if (log.id) {
58
- console.log(chalk.gray(log.id));
59
- }
60
- (_a = log.ids) == null ? void 0 : _a.map((id) => {
61
- console.log(chalk.gray(id));
62
- });
63
- return defaultHandler(level, log);
64
- },
65
- plugins: [commonjs(), externalDeps(), nodeExternals(), json(), tsPlugIn]
66
- };
67
- const outputOptions = {
68
- dir: subDir ? `dist/${subDir}` : "dist",
69
- dynamicImportInCjs: true,
70
- entryFileNames: (chunkInfo) => `${chunkInfo.name}.${ext}`,
71
- format,
72
- sourcemap: true
73
- };
74
- if (input.length) {
75
- await (await rollup(options)).write(outputOptions);
76
- }
77
- return errors.length + warnings.length;
78
- };
79
- const packageCompileRollup = async (params) => {
80
- var _a, _b;
81
- const config = await loadConfig(params);
82
- const pkg = await loadPackageConfig();
83
- const inputDirs = await getInputDirs((_a = config.compile) == null ? void 0 : _a.depth);
84
- const verbose = config.verbose;
85
- const publint = (_b = config.compile) == null ? void 0 : _b.publint;
86
- const pkgType = pkg.type ?? "commonjs";
87
- const esmExt = pkgType === "module" ? "js" : "mjs";
88
- const cjsExt = pkgType === "commonjs" ? "js" : "cjs";
89
- const result = (await Promise.all(
90
- inputDirs.map(async (inputDir) => {
91
- return await compileSubDir("cjs", cjsExt, inputDir, verbose) + await compileSubDir("esm", esmExt, inputDir, verbose);
92
- })
93
- )).reduce((prev, result2) => prev + result2, 0);
94
- return result + (publint ? await packagePublint() : 0);
95
- };
96
- export {
97
- compileSubDir,
98
- packageCompileRollup
99
- };
100
- //# sourceMappingURL=rollup.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/rollup.ts"],"sourcesContent":["import commonjs from '@rollup/plugin-commonjs'\nimport json from '@rollup/plugin-json'\nimport typescript from '@rollup/plugin-typescript'\nimport chalk from 'chalk'\nimport { OutputOptions, rollup, RollupLog, RollupOptions } from 'rollup'\nimport externalDeps from 'rollup-plugin-exclude-dependencies-from-bundle'\nimport nodeExternals from 'rollup-plugin-node-externals'\n\nimport { loadConfig } from '../../../lib'\nimport { loadPackageConfig } from '../../../loadPackageConfig'\nimport { packagePublint } from '../publint'\nimport { CompileParams } from './CompileParams'\nimport { getInputDirs, getInputs } from './inputs'\n\nexport interface PackageCompileRollupParams extends CompileParams {}\n\nexport const compileSubDir = async (format: 'cjs' | 'esm', ext: string, subDir?: string, _verbose = false) => {\n const dir = subDir === '.' ? undefined : subDir\n const input = await getInputs(dir)\n const tsPlugIn = typescript({\n baseUrl: 'src',\n declaration: !dir || !subDir,\n declarationMap: !dir || !subDir,\n emitDeclarationOnly: false,\n esModuleInterop: true,\n exclude: ['**/*.spec.*', 'dist', 'docs', 'node_modules', 'packages'],\n outDir: dir ? `dist/${dir}` : 'dist',\n rootDir: 'src',\n tsconfig: 'tsconfig.json',\n })\n\n const errors: RollupLog[] = []\n const warnings: RollupLog[] = []\n const infos: RollupLog[] = []\n const debugs: RollupLog[] = []\n\n const options: RollupOptions = {\n input: subDir ? input.map((file) => `./src/${file}`) : ['./src/index.ts'],\n logLevel: 'warn',\n onLog: (level, log, defaultHandler) => {\n const pushLog = !(log.code === 'EMPTY_BUNDLE' || log.code === 'MIXED_EXPORTS' || log.code === 'UNUSED_EXTERNAL_IMPORT')\n if (pushLog) {\n switch (level) {\n case 'warn': {\n warnings.push(log)\n break\n }\n case 'info': {\n infos.push(log)\n break\n }\n case 'debug': {\n debugs.push(log)\n break\n }\n default: {\n errors.push(log)\n break\n }\n }\n }\n console.log(chalk.yellow(`${level}: ${log.message} [${log.code}]`))\n if (log.id) {\n console.log(chalk.gray(log.id))\n }\n log.ids?.map((id) => {\n console.log(chalk.gray(id))\n })\n return defaultHandler(level, log)\n },\n plugins: [commonjs(), externalDeps(), nodeExternals(), json(), tsPlugIn],\n }\n\n const outputOptions: OutputOptions = {\n dir: subDir ? `dist/${subDir}` : 'dist',\n dynamicImportInCjs: true,\n entryFileNames: (chunkInfo) => `${chunkInfo.name}.${ext}`,\n format,\n sourcemap: true,\n }\n\n if (input.length) {\n await (await rollup(options)).write(outputOptions)\n }\n\n return errors.length + warnings.length\n}\n\nexport const packageCompileRollup = async (params?: PackageCompileRollupParams) => {\n const config = await loadConfig(params)\n const pkg = await loadPackageConfig()\n const inputDirs = await getInputDirs(config.compile?.depth)\n const verbose = config.verbose\n const publint = config.compile?.publint\n\n const pkgType = pkg.type ?? 'commonjs'\n\n const esmExt = pkgType === 'module' ? 'js' : 'mjs'\n const cjsExt = pkgType === 'commonjs' ? 'js' : 'cjs'\n\n const result = (\n await Promise.all(\n inputDirs.map(async (inputDir) => {\n return (await compileSubDir('cjs', cjsExt, inputDir, verbose)) + (await compileSubDir('esm', esmExt, inputDir, verbose))\n }),\n )\n ).reduce((prev, result) => prev + result, 0)\n return result + (publint ? await packagePublint() : 0)\n}\n"],"mappings":"AAAA,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,OAAO,WAAW;AAClB,SAAwB,cAAwC;AAChE,OAAO,kBAAkB;AACzB,OAAO,mBAAmB;AAE1B,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAE/B,SAAS,cAAc,iBAAiB;AAIjC,MAAM,gBAAgB,OAAO,QAAuB,KAAa,QAAiB,WAAW,UAAU;AAC5G,QAAM,MAAM,WAAW,MAAM,SAAY;AACzC,QAAM,QAAQ,MAAM,UAAU,GAAG;AACjC,QAAM,WAAW,WAAW;AAAA,IAC1B,SAAS;AAAA,IACT,aAAa,CAAC,OAAO,CAAC;AAAA,IACtB,gBAAgB,CAAC,OAAO,CAAC;AAAA,IACzB,qBAAqB;AAAA,IACrB,iBAAiB;AAAA,IACjB,SAAS,CAAC,eAAe,QAAQ,QAAQ,gBAAgB,UAAU;AAAA,IACnE,QAAQ,MAAM,QAAQ,GAAG,KAAK;AAAA,IAC9B,SAAS;AAAA,IACT,UAAU;AAAA,EACZ,CAAC;AAED,QAAM,SAAsB,CAAC;AAC7B,QAAM,WAAwB,CAAC;AAC/B,QAAM,QAAqB,CAAC;AAC5B,QAAM,SAAsB,CAAC;AAE7B,QAAM,UAAyB;AAAA,IAC7B,OAAO,SAAS,MAAM,IAAI,CAAC,SAAS,SAAS,IAAI,EAAE,IAAI,CAAC,gBAAgB;AAAA,IACxE,UAAU;AAAA,IACV,OAAO,CAAC,OAAO,KAAK,mBAAmB;AAvC3C;AAwCM,YAAM,UAAU,EAAE,IAAI,SAAS,kBAAkB,IAAI,SAAS,mBAAmB,IAAI,SAAS;AAC9F,UAAI,SAAS;AACX,gBAAQ,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,QAAM,UAAU,IAAI,QAAQ;AAE5B,QAAM,SAAS,YAAY,WAAW,OAAO;AAC7C,QAAM,SAAS,YAAY,aAAa,OAAO;AAE/C,QAAM,UACJ,MAAM,QAAQ;AAAA,IACZ,UAAU,IAAI,OAAO,aAAa;AAChC,aAAQ,MAAM,cAAc,OAAO,QAAQ,UAAU,OAAO,IAAM,MAAM,cAAc,OAAO,QAAQ,UAAU,OAAO;AAAA,IACxH,CAAC;AAAA,EACH,GACA,OAAO,CAAC,MAAMA,YAAW,OAAOA,SAAQ,CAAC;AAC3C,SAAO,UAAU,UAAU,MAAM,eAAe,IAAI;AACtD;","names":["result"]}
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var tsc_exports = {};
30
- __export(tsc_exports, {
31
- packageCompileTsc: () => packageCompileTsc
32
- });
33
- module.exports = __toCommonJS(tsc_exports);
34
- var import_chalk = __toESM(require("chalk"));
35
- var import_merge = __toESM(require("lodash/merge"));
36
- var import_typescript = require("typescript");
37
- var import_lib = require("../../../lib");
38
- var import_getCompilerOptions = require("./getCompilerOptions");
39
- var import_inputs = require("./inputs");
40
- const getConfigFile = (options, tsconfig = "tsconfig.json") => {
41
- const configFileName = (0, import_typescript.findConfigFile)("./", import_typescript.sys.fileExists, tsconfig);
42
- return { ...configFileName ? (0, import_typescript.readConfigFile)(configFileName, import_typescript.sys.readFile).config : {}, compilerOptions: (0, import_getCompilerOptions.getCompilerOptions)(options) };
43
- };
44
- const compile = (fileNames, options) => {
45
- console.log(import_chalk.default.blue("compile"));
46
- console.log(import_chalk.default.magenta(`options: ${JSON.stringify(options, null, 2)}`));
47
- const program = (0, import_typescript.createProgram)(fileNames, options);
48
- console.log(import_chalk.default.blue("createProgram"));
49
- const emitResult = program.emit();
50
- console.log(import_chalk.default.blue("emit"));
51
- const allDiagnostics = (0, import_typescript.getPreEmitDiagnostics)(program).concat(emitResult.diagnostics);
52
- const errorDiagnostics = allDiagnostics.filter((diagnostic) => diagnostic.category === 1);
53
- allDiagnostics.forEach((diagnostic) => {
54
- if (diagnostic.file) {
55
- const { line, character } = (0, import_typescript.getLineAndCharacterOfPosition)(diagnostic.file, diagnostic.start);
56
- const message = (0, import_typescript.flattenDiagnosticMessageText)(diagnostic.messageText, "\n");
57
- console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
58
- } else {
59
- console.log((0, import_typescript.flattenDiagnosticMessageText)(diagnostic.messageText, "\n"));
60
- }
61
- });
62
- if (errorDiagnostics.length) {
63
- console.log(import_chalk.default.red(`Errors: ${errorDiagnostics.length}`));
64
- process.exit(errorDiagnostics.length);
65
- }
66
- return errorDiagnostics.length;
67
- };
68
- const packageCompileTsc = async (params) => {
69
- var _a, _b, _c;
70
- const defaultCompilerOptions = {
71
- declaration: true,
72
- declarationMap: true,
73
- outDir: "dist",
74
- rootDir: "src",
75
- sourceMap: true
76
- };
77
- const compilerOptions = (0, import_merge.default)({}, defaultCompilerOptions, (_b = (_a = params == null ? void 0 : params.compile) == null ? void 0 : _a.tsc) == null ? void 0 : _b.compilerOptions);
78
- const config = await (0, import_lib.loadConfig)(params);
79
- if (config.verbose) {
80
- console.log("Compiling with TSC");
81
- }
82
- const fileNames = (await (0, import_inputs.getAllInputs)((_c = config.compile) == null ? void 0 : _c.depth)).map((fileName) => `src/${fileName}`);
83
- const configFile = getConfigFile(compilerOptions);
84
- return compile(fileNames, configFile.compilerOptions);
85
- };
86
- // Annotate the CommonJS export names for ESM import in node:
87
- 0 && (module.exports = {
88
- packageCompileTsc
89
- });
90
- //# sourceMappingURL=tsc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/tsc.ts"],"sourcesContent":["import chalk from 'chalk'\n// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge'\nimport {\n CompilerOptions,\n createProgram,\n Diagnostic,\n findConfigFile,\n flattenDiagnosticMessageText,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n readConfigFile,\n sys,\n} from 'typescript'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { getCompilerOptions } from './getCompilerOptions'\nimport { getAllInputs } from './inputs'\n\nexport type PackageCompileTscParams = Partial<\n CompileParams & {\n compile?: {\n tsc?: {\n compilerOptions?: CompilerOptions\n tsconfig?: string\n }\n }\n }\n>\n\nconst getConfigFile = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json') => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n return { ...(configFileName ? readConfigFile(configFileName, sys.readFile).config : {}), compilerOptions: getCompilerOptions(options) }\n}\n\nconst compile = (fileNames: string[], options: CompilerOptions) => {\n console.log(chalk.blue('compile'))\n console.log(chalk.magenta(`options: ${JSON.stringify(options, null, 2)}`))\n const program = createProgram(fileNames, options)\n console.log(chalk.blue('createProgram'))\n const emitResult = program.emit()\n console.log(chalk.blue('emit'))\n\n const allDiagnostics: Diagnostic[] = getPreEmitDiagnostics(program).concat(emitResult.diagnostics)\n\n const errorDiagnostics = allDiagnostics.filter((diagnostic) => diagnostic.category === 1)\n\n allDiagnostics.forEach((diagnostic) => {\n if (diagnostic.file) {\n const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start!)\n const message = flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)\n } else {\n console.log(flattenDiagnosticMessageText(diagnostic.messageText, '\\n'))\n }\n })\n\n if (errorDiagnostics.length) {\n console.log(chalk.red(`Errors: ${errorDiagnostics.length}`))\n process.exit(errorDiagnostics.length)\n }\n\n return errorDiagnostics.length\n}\n\nexport const packageCompileTsc = async (params?: PackageCompileTscParams): Promise<number> => {\n const defaultCompilerOptions: CompilerOptions = {\n declaration: true,\n declarationMap: true,\n outDir: 'dist',\n rootDir: 'src',\n sourceMap: true,\n }\n const compilerOptions = merge({}, defaultCompilerOptions, params?.compile?.tsc?.compilerOptions)\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log('Compiling with TSC')\n }\n\n const fileNames = (await getAllInputs(config.compile?.depth)).map((fileName) => `src/${fileName}`)\n const configFile = getConfigFile(compilerOptions)\n return compile(fileNames, configFile.compilerOptions)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,mBAAkB;AAClB,wBAUO;AAEP,iBAA2B;AAE3B,gCAAmC;AACnC,oBAA6B;AAa7B,MAAM,gBAAgB,CAAC,SAA2B,WAAmB,oBAAoB;AACvF,QAAM,qBAAiB,kCAAe,MAAM,sBAAI,YAAY,QAAQ;AACpE,SAAO,EAAE,GAAI,qBAAiB,kCAAe,gBAAgB,sBAA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T,WAAW;AAAA,EACb;AACA,QAAM,sBAAkB,aAAAC,SAAM,CAAC,GAAG,yBAAwB,4CAAQ,YAAR,mBAAiB,QAAjB,mBAAsB,eAAe;AAC/F,QAAM,SAAS,UAAM,uBAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,oBAAoB;AAAA,EAClC;AAEA,QAAM,aAAa,UAAM,6BAAa,YAAO,YAAP,mBAAgB,KAAK,GAAG,IAAI,CAAC,aAAa,OAAO,QAAQ,EAAE;AACjG,QAAM,aAAa,cAAc,eAAe;AAChD,SAAO,QAAQ,WAAW,WAAW,eAAe;AACtD;","names":["chalk","merge"]}
@@ -1,64 +0,0 @@
1
- import chalk from "chalk";
2
- import merge from "lodash/merge";
3
- import {
4
- createProgram,
5
- findConfigFile,
6
- flattenDiagnosticMessageText,
7
- getLineAndCharacterOfPosition,
8
- getPreEmitDiagnostics,
9
- readConfigFile,
10
- sys
11
- } from "typescript";
12
- import { loadConfig } from "../../../lib";
13
- import { getCompilerOptions } from "./getCompilerOptions";
14
- import { getAllInputs } from "./inputs";
15
- const getConfigFile = (options, tsconfig = "tsconfig.json") => {
16
- const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
17
- return { ...configFileName ? readConfigFile(configFileName, sys.readFile).config : {}, compilerOptions: getCompilerOptions(options) };
18
- };
19
- const compile = (fileNames, options) => {
20
- console.log(chalk.blue("compile"));
21
- console.log(chalk.magenta(`options: ${JSON.stringify(options, null, 2)}`));
22
- const program = createProgram(fileNames, options);
23
- console.log(chalk.blue("createProgram"));
24
- const emitResult = program.emit();
25
- console.log(chalk.blue("emit"));
26
- const allDiagnostics = getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
27
- const errorDiagnostics = allDiagnostics.filter((diagnostic) => diagnostic.category === 1);
28
- allDiagnostics.forEach((diagnostic) => {
29
- if (diagnostic.file) {
30
- const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
31
- const message = flattenDiagnosticMessageText(diagnostic.messageText, "\n");
32
- console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
33
- } else {
34
- console.log(flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
35
- }
36
- });
37
- if (errorDiagnostics.length) {
38
- console.log(chalk.red(`Errors: ${errorDiagnostics.length}`));
39
- process.exit(errorDiagnostics.length);
40
- }
41
- return errorDiagnostics.length;
42
- };
43
- const packageCompileTsc = async (params) => {
44
- var _a, _b, _c;
45
- const defaultCompilerOptions = {
46
- declaration: true,
47
- declarationMap: true,
48
- outDir: "dist",
49
- rootDir: "src",
50
- sourceMap: true
51
- };
52
- const compilerOptions = merge({}, defaultCompilerOptions, (_b = (_a = params == null ? void 0 : params.compile) == null ? void 0 : _a.tsc) == null ? void 0 : _b.compilerOptions);
53
- const config = await loadConfig(params);
54
- if (config.verbose) {
55
- console.log("Compiling with TSC");
56
- }
57
- const fileNames = (await getAllInputs((_c = config.compile) == null ? void 0 : _c.depth)).map((fileName) => `src/${fileName}`);
58
- const configFile = getConfigFile(compilerOptions);
59
- return compile(fileNames, configFile.compilerOptions);
60
- };
61
- export {
62
- packageCompileTsc
63
- };
64
- //# sourceMappingURL=tsc.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/tsc.ts"],"sourcesContent":["import chalk from 'chalk'\n// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge'\nimport {\n CompilerOptions,\n createProgram,\n Diagnostic,\n findConfigFile,\n flattenDiagnosticMessageText,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n readConfigFile,\n sys,\n} from 'typescript'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { getCompilerOptions } from './getCompilerOptions'\nimport { getAllInputs } from './inputs'\n\nexport type PackageCompileTscParams = Partial<\n CompileParams & {\n compile?: {\n tsc?: {\n compilerOptions?: CompilerOptions\n tsconfig?: string\n }\n }\n }\n>\n\nconst getConfigFile = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json') => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n return { ...(configFileName ? readConfigFile(configFileName, sys.readFile).config : {}), compilerOptions: getCompilerOptions(options) }\n}\n\nconst compile = (fileNames: string[], options: CompilerOptions) => {\n console.log(chalk.blue('compile'))\n console.log(chalk.magenta(`options: ${JSON.stringify(options, null, 2)}`))\n const program = createProgram(fileNames, options)\n console.log(chalk.blue('createProgram'))\n const emitResult = program.emit()\n console.log(chalk.blue('emit'))\n\n const allDiagnostics: Diagnostic[] = getPreEmitDiagnostics(program).concat(emitResult.diagnostics)\n\n const errorDiagnostics = allDiagnostics.filter((diagnostic) => diagnostic.category === 1)\n\n allDiagnostics.forEach((diagnostic) => {\n if (diagnostic.file) {\n const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start!)\n const message = flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)\n } else {\n console.log(flattenDiagnosticMessageText(diagnostic.messageText, '\\n'))\n }\n })\n\n if (errorDiagnostics.length) {\n console.log(chalk.red(`Errors: ${errorDiagnostics.length}`))\n process.exit(errorDiagnostics.length)\n }\n\n return errorDiagnostics.length\n}\n\nexport const packageCompileTsc = async (params?: PackageCompileTscParams): Promise<number> => {\n const defaultCompilerOptions: CompilerOptions = {\n declaration: true,\n declarationMap: true,\n outDir: 'dist',\n rootDir: 'src',\n sourceMap: true,\n }\n const compilerOptions = merge({}, defaultCompilerOptions, params?.compile?.tsc?.compilerOptions)\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log('Compiling with TSC')\n }\n\n const fileNames = (await getAllInputs(config.compile?.depth)).map((fileName) => `src/${fileName}`)\n const configFile = getConfigFile(compilerOptions)\n return compile(fileNames, configFile.compilerOptions)\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAElB,OAAO,WAAW;AAClB;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA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CAAC;AAC3D,YAAQ,KAAK,iBAAiB,MAAM;AAAA,EACtC;AAEA,SAAO,iBAAiB;AAC1B;AAEO,MAAM,oBAAoB,OAAO,WAAsD;AAlE9F;AAmEE,QAAM,yBAA0C;AAAA,IAC9C,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACA,QAAM,kBAAkB,MAAM,CAAC,GAAG,yBAAwB,4CAAQ,YAAR,mBAAiB,QAAjB,mBAAsB,eAAe;AAC/F,QAAM,SAAS,MAAM,WAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,oBAAoB;AAAA,EAClC;AAEA,QAAM,aAAa,MAAM,cAAa,YAAO,YAAP,mBAAgB,KAAK,GAAG,IAAI,CAAC,aAAa,OAAO,QAAQ,EAAE;AACjG,QAAM,aAAa,cAAc,eAAe;AAChD,SAAO,QAAQ,WAAW,WAAW,eAAe;AACtD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/tscNoEmit.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { cwd } from 'process'\nimport { createProgramFromConfig, TsConfigCompilerOptions } from 'tsc-prog'\nimport {\n CompilerOptions,\n DiagnosticCategory,\n FormatDiagnosticsHost,\n formatDiagnosticsWithColorAndContext,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n LineAndCharacter,\n} from 'typescript'\n\nimport { CompileParams } from './CompileParams'\nimport { getCompilerOptions } from './getCompilerOptions'\n\nexport const packageCompileTscNoEmit = (params?: CompileParams, compilerOptionsParam?: CompilerOptions): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n\n const formatHost: FormatDiagnosticsHost = {\n getCanonicalFileName: (fileName) => fileName,\n getCurrentDirectory: () => pkg,\n getNewLine: () => '\\n',\n }\n\n if (params?.verbose) {\n console.log(`Compiling with NoEmit TSC [${pkg}]`)\n }\n\n const compilerOptions = {\n ...getCompilerOptions({\n declaration: true,\n declarationMap: true,\n emitDeclarationOnly: true,\n esModuleInterop: true,\n outDir: 'dist',\n rootDir: 'src',\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: true,\n }),\n ...(compilerOptionsParam ?? {}),\n } as TsConfigCompilerOptions\n\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n exclude: ['dist', 'docs', '**/*.spec.*', '**/*.stories.*', 'src/**/spec/**/*'],\n include: ['src'],\n })\n\n const results = getPreEmitDiagnostics(program)\n\n results.forEach((diag) => {\n const lineAndChar: LineAndCharacter = diag.file ? getLineAndCharacterOfPosition(diag.file, diag.start ?? 0) : { character: 0, line: 0 }\n console.log(chalk.cyan(`${diag.file?.fileName}:${lineAndChar.line + 1}:${lineAndChar.character + 1}`))\n console.log(formatDiagnosticsWithColorAndContext([diag], formatHost))\n })\n\n return results.reduce((prev, diag) => (prev + diag.category === DiagnosticCategory.Error ? 1 : 0), 0)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,qBAAoB;AACpB,sBAAiE;AACjE,wBAQO;AAGP,gCAAmC;AAE5B,MAAM,0BAA0B,CAAC,QAAwB,yBAAmD;AACjH,QAAM,MAAM,QAAQ,IAAI,gBAAY,oBAAI;AAExC,QAAM,aAAoC;AAAA,IACxC,sBAAsB,CAAC,aAAa;AAAA,IACpC,qBAAqB,MAAM;AAAA,IAC3B,YAAY,MAAM;AAAA,EACpB;AAEA,MAAI,iCAAQ,SAAS;AACnB,YAAQ,IAAI,8BAA8B,GAAG,GAAG;AAAA,EAClD;AAEA,QAAM,kBAAkB;AAAA,IACtB,OAAG,8CAAmB;AAAA,MACpB,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,qBAAqB;AAAA,MACrB,iBAAiB;AAAA,MACjB,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,qBAAqB;AAAA,MACrB,cAAc;AAAA,MACd,WAAW;AAAA,IACb,CAAC;AAAA,IACD,GAAI,wBAAwB,CAAC;AAAA,EAC/B;AAEA,QAAM,cAAU,yCAAwB;AAAA,IACtC,UAAU,WAAO,oBAAI;AAAA,IACrB;AAAA,IACA,SAAS,CAAC,QAAQ,QAAQ,eAAe,kBAAkB,kBAAkB;AAAA,IAC7E,SAAS,CAAC,KAAK;AAAA,EACjB,CAAC;AAED,QAAM,cAAU,yCAAsB,OAAO;AAE7C,UAAQ,QAAQ,CAAC,SAAS;AArD5B;AAsDI,UAAM,cAAgC,KAAK,WAAO,iDAA8B,KAAK,MAAM,KAAK,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE;AACtI,YAAQ,IAAI,aAAAA,QAAM,KAAK,IAAG,UAAK,SAAL,mBAAW,QAAQ,IAAI,YAAY,OAAO,CAAC,IAAI,YAAY,YAAY,CAAC,EAAE,CAAC;AACrG,YAAQ,QAAI,wDAAqC,CAAC,IAAI,GAAG,UAAU,CAAC;AAAA,EACtE,CAAC;AAED,SAAO,QAAQ,OAAO,CAAC,MAAM,SAAU,OAAO,KAAK,aAAa,qCAAmB,QAAQ,IAAI,GAAI,CAAC;AACtG;","names":["chalk"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/tscNoEmit.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { cwd } from 'process'\nimport { createProgramFromConfig, TsConfigCompilerOptions } from 'tsc-prog'\nimport {\n CompilerOptions,\n DiagnosticCategory,\n FormatDiagnosticsHost,\n formatDiagnosticsWithColorAndContext,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n LineAndCharacter,\n} from 'typescript'\n\nimport { CompileParams } from './CompileParams'\nimport { getCompilerOptions } from './getCompilerOptions'\n\nexport const packageCompileTscNoEmit = (params?: CompileParams, compilerOptionsParam?: CompilerOptions): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n\n const formatHost: FormatDiagnosticsHost = {\n getCanonicalFileName: (fileName) => fileName,\n getCurrentDirectory: () => pkg,\n getNewLine: () => '\\n',\n }\n\n if (params?.verbose) {\n console.log(`Compiling with NoEmit TSC [${pkg}]`)\n }\n\n const compilerOptions = {\n ...getCompilerOptions({\n declaration: true,\n declarationMap: true,\n emitDeclarationOnly: true,\n esModuleInterop: true,\n outDir: 'dist',\n rootDir: 'src',\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: true,\n }),\n ...(compilerOptionsParam ?? {}),\n } as TsConfigCompilerOptions\n\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n exclude: ['dist', 'docs', '**/*.spec.*', '**/*.stories.*', 'src/**/spec/**/*'],\n include: ['src'],\n })\n\n const results = getPreEmitDiagnostics(program)\n\n results.forEach((diag) => {\n const lineAndChar: LineAndCharacter = diag.file ? getLineAndCharacterOfPosition(diag.file, diag.start ?? 0) : { character: 0, line: 0 }\n console.log(chalk.cyan(`${diag.file?.fileName}:${lineAndChar.line + 1}:${lineAndChar.character + 1}`))\n console.log(formatDiagnosticsWithColorAndContext([diag], formatHost))\n })\n\n return results.reduce((prev, diag) => (prev + diag.category === DiagnosticCategory.Error ? 1 : 0), 0)\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAClB,SAAS,WAAW;AACpB,SAAS,+BAAwD;AACjE;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAGP,SAAS,0BAA0B;AAE5B,MAAM,0BAA0B,CAAC,QAAwB,yBAAmD;AACjH,QAAM,MAAM,QAAQ,IAAI,YAAY,IAAI;AAExC,QAAM,aAAoC;AAAA,IACxC,sBAAsB,CAAC,aAAa;AAAA,IACpC,qBAAqB,MAAM;AAAA,IAC3B,YAAY,MAAM;AAAA,EACpB;AAEA,MAAI,iCAAQ,SAAS;AACnB,YAAQ,IAAI,8BAA8B,GAAG,GAAG;AAAA,EAClD;AAEA,QAAM,kBAAkB;AAAA,IACtB,GAAG,mBA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