@gravity-ui/app-builder 0.2.2 → 0.3.0

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 (35) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +226 -1
  3. package/dist/commands/build/build-lib.js +2 -5
  4. package/dist/commands/build/index.js +1 -2
  5. package/dist/commands/dev/client.js +30 -25
  6. package/dist/commands/dev/index.js +10 -8
  7. package/dist/commands/dev/server.js +3 -3
  8. package/dist/common/child-process/controllable-script.js +3 -1
  9. package/dist/common/child-process/utils.js +1 -2
  10. package/dist/common/config.d.ts +1 -1
  11. package/dist/common/config.js +34 -26
  12. package/dist/common/library/index.js +13 -13
  13. package/dist/common/links/unlink.js +2 -2
  14. package/dist/common/logger/index.js +1 -2
  15. package/dist/common/models/index.d.ts +11 -9
  16. package/dist/common/models/index.js +5 -1
  17. package/dist/common/package.js +5 -2
  18. package/dist/common/s3-upload/s3-client.d.ts +1 -0
  19. package/dist/common/s3-upload/s3-client.js +2 -14
  20. package/dist/common/s3-upload/upload.d.ts +1 -1
  21. package/dist/common/s3-upload/upload.js +1 -2
  22. package/dist/common/s3-upload/webpack-plugin.d.ts +1 -1
  23. package/dist/common/s3-upload/webpack-plugin.js +4 -2
  24. package/dist/common/tempData.js +1 -1
  25. package/dist/common/typescript/diagnostic.js +1 -1
  26. package/dist/common/typescript/transformers.js +39 -7
  27. package/dist/common/typescript/watch.js +7 -2
  28. package/dist/common/webpack/config.js +62 -55
  29. package/dist/common/webpack/storybook.js +43 -14
  30. package/dist/common/webpack/utils.js +5 -3
  31. package/dist/create-cli.d.ts +2 -2
  32. package/dist/create-cli.js +1 -1
  33. package/dist/index.d.ts +2 -1
  34. package/dist/index.js +3 -1
  35. package/package.json +40 -41
@@ -33,7 +33,7 @@ const fs_1 = __importDefault(require("fs"));
33
33
  const child_process_1 = __importDefault(require("child_process"));
34
34
  const babel = __importStar(require("@babel/core"));
35
35
  const fast_glob_1 = __importDefault(require("fast-glob"));
36
- const rimraf_1 = __importDefault(require("rimraf"));
36
+ const rimraf_1 = require("rimraf");
37
37
  const sass_1 = __importDefault(require("sass"));
38
38
  const postcss_1 = __importDefault(require("postcss"));
39
39
  const postcss_preset_env_1 = __importDefault(require("postcss-preset-env"));
@@ -83,14 +83,13 @@ function compileToCjs(code, file, inputSourceMap, sourceDir = paths_1.default.sr
83
83
  sourceMaps: true,
84
84
  inputSourceMap,
85
85
  }, (err, transformedCjs) => {
86
- var _a;
87
86
  if (err) {
88
87
  logger_1.default.error(`Source compilation errors for ${sourceFile}`);
89
88
  logger_1.default.error(err.toString());
90
89
  throw err;
91
90
  }
92
91
  else if (transformedCjs) {
93
- let cjsCode = (_a = transformedCjs.code) !== null && _a !== void 0 ? _a : '';
92
+ let cjsCode = transformedCjs.code ?? '';
94
93
  cjsCode += (cjsCode.length ? '\n' : '') + sourcemapCjsUrl;
95
94
  fs_1.default.writeFile(compiledCjsFile, cjsCode, errorHandlerFactory(`Source compilation has failed on writing ${compiledCjsFile}`));
96
95
  if (transformedCjs.map) {
@@ -121,7 +120,6 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
121
120
  : ['**/*.{sass,scss,css}'];
122
121
  const stylesStream = fast_glob_1.default.stream(globs, { cwd: outputDir });
123
122
  stylesStream.on('data', async (file) => {
124
- var _a;
125
123
  const origScssFile = getFilePath(file, { dir: inputDir });
126
124
  const scssFile = getFilePath(file, { dir: outputDir });
127
125
  const cssFile = getFilePath(file, { dir: outputDir, ext: 'css' });
@@ -139,12 +137,12 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
139
137
  return new Error(`Unrecognized import ${url} in ${origScssFile}`);
140
138
  },
141
139
  });
142
- if (sassTransformed === null || sassTransformed === void 0 ? void 0 : sassTransformed.css) {
140
+ if (sassTransformed?.css) {
143
141
  const postcssTransformed = await (0, postcss_1.default)([
144
142
  (0, postcss_preset_env_1.default)({ enableClientSidePolyfills: false }),
145
143
  ]).process(sassTransformed.css, {
146
144
  to: cssFile.split('/').pop(),
147
- map: { prev: (_a = sassTransformed.map) === null || _a === void 0 ? void 0 : _a.toString(), inline: false },
145
+ map: { prev: sassTransformed.map?.toString(), inline: false },
148
146
  });
149
147
  fs_1.default.writeFileSync(cssFile, postcssTransformed.css);
150
148
  if (postcssTransformed.map) {
@@ -167,9 +165,8 @@ const svgoPreset = {
167
165
  params: { overrides: { removeViewBox: false } },
168
166
  };
169
167
  function buildLibrary(config) {
170
- var _a, _b, _c;
171
- const internalGlobs = (_c = (_b = (_a = config.lib) === null || _a === void 0 ? void 0 : _a.internalDirs) === null || _b === void 0 ? void 0 : _b.map((dir) => `!${dir}/**/*`)) !== null && _c !== void 0 ? _c : [];
172
- rimraf_1.default.sync(paths_1.default.libBuild);
168
+ const internalGlobs = config.lib?.internalDirs?.map((dir) => `!${dir}/**/*`) ?? [];
169
+ rimraf_1.rimraf.sync(paths_1.default.libBuild);
173
170
  // sources compilation
174
171
  const sourceStream = fast_glob_1.default.stream(['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts', ...internalGlobs], {
175
172
  cwd: paths_1.default.src,
@@ -184,7 +181,7 @@ function buildLibrary(config) {
184
181
  fs_1.default.mkdirSync(compiledDir, { recursive: true });
185
182
  babel.transform(source, {
186
183
  filename: sourceFile,
187
- presets: [(0, babel_1.babelPreset)(config)],
184
+ presets: [(0, babel_1.babelPreset)(config.lib)],
188
185
  plugins: [
189
186
  [
190
187
  require.resolve('babel-plugin-inline-react-svg'),
@@ -199,14 +196,17 @@ function buildLibrary(config) {
199
196
  ],
200
197
  sourceMaps: true,
201
198
  }, (err, transformed) => {
202
- var _a, _b, _c, _d, _e;
203
199
  if (err) {
204
200
  logger_1.default.error(`Source compilation errors for ${sourceFile}`);
205
201
  logger_1.default.error(err.toString());
206
202
  throw err;
207
203
  }
208
204
  else if (transformed) {
209
- let code = (_e = (_d = (_c = (_b = (_a = transformed.code) === null || _a === void 0 ? void 0 : _a.replace(/import '\.(.*)\.scss';/g, "import '.$1.css';")) === null || _b === void 0 ? void 0 : _b.replace(/import (\w*) from '\.\.\/(.*)\/assets\/(.*)\.svg';/g, "import $1 from '$2/assets/$3';")) === null || _c === void 0 ? void 0 : _c.replace(/export { *default as (\w*) *} from '\.\.\/(.*)\/assets\/(.*)\.svg';/g, "export { default as $1 } from '$2/assets/$3';")) === null || _d === void 0 ? void 0 : _d.replace(/import\('\.\.\/(.*)\/assets\/(.*)\.svg'\)/g, "import('$1/assets/$2')")) !== null && _e !== void 0 ? _e : '';
205
+ let code = transformed.code
206
+ ?.replace(/import '\.(.*)\.scss';/g, "import '.$1.css';")
207
+ ?.replace(/import (\w*) from '\.\.\/(.*)\/assets\/(.*)\.svg';/g, "import $1 from '$2/assets/$3';")
208
+ ?.replace(/export { *default as (\w*) *} from '\.\.\/(.*)\/assets\/(.*)\.svg';/g, "export { default as $1 } from '$2/assets/$3';")
209
+ ?.replace(/import\('\.\.\/(.*)\/assets\/(.*)\.svg'\)/g, "import('$1/assets/$2')") ?? '';
210
210
  code += (code.length ? '\n' : '') + sourcemapUrl;
211
211
  fs_1.default.writeFile(compiledFile, code, errorHandlerFactory(`Source compilation has failed on writing ${compiledFile}`));
212
212
  if (transformed.map) {
@@ -260,7 +260,7 @@ function buildLibrary(config) {
260
260
  const component = await (0, core_1.transform)(fs_1.default.readFileSync(iconFile, 'utf-8'));
261
261
  babel.transform(component, {
262
262
  filename: iconFile,
263
- presets: [(0, babel_1.babelPreset)(config)],
263
+ presets: [(0, babel_1.babelPreset)(config.lib)],
264
264
  sourceMaps: true,
265
265
  }, (err, transformed) => {
266
266
  if (err) {
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.unlinkPackage = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const rimraf_1 = __importDefault(require("rimraf"));
8
+ const rimraf_1 = require("rimraf");
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const logger_1 = __importDefault(require("../logger"));
11
11
  const tempData_1 = __importDefault(require("../tempData"));
@@ -21,7 +21,7 @@ function unlinkPackage(linkedPackage) {
21
21
  }
22
22
  const packNodeModulesDir = path_1.default.resolve(linkedPackage.location, 'node_modules');
23
23
  const hiddenNodeModuleDir = path_1.default.resolve(linkedPackage.location, '.node_modules');
24
- rimraf_1.default.sync(packNodeModulesDir);
24
+ rimraf_1.rimraf.sync(packNodeModulesDir);
25
25
  fs_extra_1.default.moveSync(hiddenNodeModuleDir, packNodeModulesDir);
26
26
  const { linkedPackages } = tempData_1.default.getSettings();
27
27
  if (linkedPackages) {
@@ -16,7 +16,6 @@ const allColors = [
16
16
  colors_1.colors.grey.bold,
17
17
  ];
18
18
  function selectColor(namespace) {
19
- var _a;
20
19
  let hash = 0;
21
20
  for (let i = 0; i < namespace.length; i++) {
22
21
  /* eslint-disable no-bitwise */
@@ -24,7 +23,7 @@ function selectColor(namespace) {
24
23
  hash |= 0; // Convert to 32bit integer
25
24
  /* eslint-enable no-bitwise */
26
25
  }
27
- return (_a = allColors[Math.abs(hash) % allColors.length]) !== null && _a !== void 0 ? _a : colors_1.colors.green.bold;
26
+ return allColors[Math.abs(hash) % allColors.length] ?? colors_1.colors.green.bold;
28
27
  }
29
28
  class Logger {
30
29
  constructor(namespace = '', verbose = false) {
@@ -5,6 +5,7 @@ import type { Options as MomentTzOptions } from 'moment-timezone-data-webpack-pl
5
5
  import type { Configuration, ResolveOptions, DefinePlugin } from 'webpack';
6
6
  import type { ServerConfiguration } from 'webpack-dev-server';
7
7
  import type { Options as CircularDependenciesOptions } from 'circular-dependency-plugin';
8
+ import type { Config as SvgrConfig } from '@svgr/core';
8
9
  export interface Entities<T> {
9
10
  data: Record<string, T>;
10
11
  keys: string[];
@@ -34,13 +35,13 @@ interface ContextReplacement {
34
35
  locale?: string[];
35
36
  }
36
37
  export interface LibraryConfig {
37
- lib?: {
38
+ lib: {
38
39
  internalDirs?: string[];
40
+ /**
41
+ * Use new JSX Transform
42
+ */
43
+ newJsxTransform?: boolean;
39
44
  };
40
- /**
41
- * Use new JSX Transform
42
- */
43
- newJsxTransform?: boolean;
44
45
  verbose?: boolean;
45
46
  }
46
47
  export interface ClientConfig {
@@ -54,7 +55,7 @@ export interface ClientConfig {
54
55
  */
55
56
  includes?: string[];
56
57
  /**
57
- * Additional paths fro images
58
+ * Additional paths for images
58
59
  */
59
60
  images?: string[];
60
61
  /**
@@ -111,7 +112,7 @@ export interface ClientConfig {
111
112
  /**
112
113
  * svgr plugin options.
113
114
  */
114
- svgr?: Object;
115
+ svgr?: SvgrConfig;
115
116
  entryFilter?: string[];
116
117
  excludeFromClean?: string[];
117
118
  analyzeBundle?: 'true' | 'statoscope';
@@ -162,7 +163,7 @@ export interface ServiceConfig {
162
163
  target?: 'client' | 'server';
163
164
  client?: ClientConfig;
164
165
  server?: ServerConfig;
165
- link?: string;
166
+ lib?: never;
166
167
  verbose?: boolean;
167
168
  }
168
169
  export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer'> & {
@@ -188,7 +189,8 @@ export type NormalizedServiceConfig = Omit<ServiceConfig, 'client' | 'server'> &
188
189
  };
189
190
  export type ProjectConfig = {} & (ServiceConfig | LibraryConfig);
190
191
  export type AppBuilderConfigPackage = (options?: unknown) => ProjectConfig;
191
- export type ProjectFileConfig = ProjectConfig | ((mode: 'dev' | 'build', env?: Record<string, any>) => ProjectConfig);
192
+ export type ProjectFileConfig = ProjectConfig | ((mode: 'dev' | 'build', env?: Record<string, any>) => ProjectConfig | Promise<ProjectConfig>);
192
193
  export declare function isServiceConfig(config: ProjectConfig): config is ServiceConfig;
193
194
  export declare function isLibraryConfig(config: ProjectConfig): config is LibraryConfig;
195
+ export declare function defineConfig(config: ProjectFileConfig): ProjectFileConfig;
194
196
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLibraryConfig = exports.isServiceConfig = void 0;
3
+ exports.defineConfig = exports.isLibraryConfig = exports.isServiceConfig = void 0;
4
4
  function isServiceConfig(config) {
5
5
  return !('lib' in config);
6
6
  }
@@ -9,3 +9,7 @@ function isLibraryConfig(config) {
9
9
  return 'lib' in config;
10
10
  }
11
11
  exports.isLibraryConfig = isLibraryConfig;
12
+ function defineConfig(config) {
13
+ return config;
14
+ }
15
+ exports.defineConfig = defineConfig;
@@ -13,7 +13,10 @@ function readPackage(location) {
13
13
  }
14
14
  try {
15
15
  const packageJson = fs_1.default.readFileSync(packageJsonLocation, 'utf-8');
16
- return Object.assign(Object.assign({}, JSON.parse(packageJson)), { location });
16
+ return {
17
+ ...JSON.parse(packageJson),
18
+ location,
19
+ };
17
20
  }
18
21
  catch (e) {
19
22
  throw new Error(`Couldn't read package.json at ${location}`);
@@ -32,7 +35,7 @@ function readNodeModules(location) {
32
35
  }
33
36
  else {
34
37
  const { data, keys } = readNodeModules(nodeModulePath);
35
- acc.data = Object.assign(Object.assign({}, acc.data), data);
38
+ acc.data = { ...acc.data, ...data };
36
39
  acc.keys = [...acc.keys, ...keys];
37
40
  }
38
41
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import type { S3ClientConfig, PutObjectCommandInput } from '@aws-sdk/client-s3';
2
3
  export type S3ClientOptions = S3ClientConfig;
3
4
  export declare function getS3Client(options: S3ClientOptions): {
@@ -22,17 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __rest = (this && this.__rest) || function (s, e) {
26
- var t = {};
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
- t[p] = s[p];
29
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
- t[p[i]] = s[p[i]];
33
- }
34
- return t;
35
- };
36
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
27
  };
@@ -73,12 +62,11 @@ function getS3Client(options) {
73
62
  ContentType: contentType,
74
63
  };
75
64
  if (expires) {
76
- params.Metadata = Object.assign(Object.assign({}, params.Metadata), { Expires: expires.toString() });
65
+ params.Metadata = { ...params.Metadata, Expires: expires.toString() };
77
66
  }
78
67
  return s3Client.send(new client_s3_1.PutObjectCommand(params));
79
68
  },
80
- uploadDir(bucket, dirPath, keyPrefix = '', _a = {}) {
81
- var { concurrency = 512 } = _a, opts = __rest(_a, ["concurrency"]);
69
+ uploadDir(bucket, dirPath, keyPrefix = '', { concurrency = 512, ...opts } = {}) {
82
70
  const files = fast_glob_1.default.sync('**', { cwd: dirPath });
83
71
  return (0, p_map_1.default)(files, (filePath) => {
84
72
  const sourcePath = path.join(dirPath, filePath);
@@ -1,4 +1,4 @@
1
- import { S3ClientOptions } from './s3-client.js';
1
+ import type { S3ClientOptions } from './s3-client.js';
2
2
  export interface UploadOptions {
3
3
  bucket: string;
4
4
  sourcePath: string;
@@ -32,10 +32,9 @@ const p_queue_1 = __importDefault(require("p-queue"));
32
32
  const s3_client_js_1 = require("./s3-client.js");
33
33
  const compress_js_1 = require("./compress.js");
34
34
  function uploadFiles(files, config) {
35
- var _a;
36
35
  const s3Client = (0, s3_client_js_1.getS3Client)(config.s3);
37
36
  const queue = new p_queue_1.default({
38
- concurrency: (_a = config.concurrency) !== null && _a !== void 0 ? _a : 512,
37
+ concurrency: config.concurrency ?? 512,
39
38
  });
40
39
  const processFile = fileProcessor(config.options);
41
40
  return Promise.all(files.flatMap((filePath) => {
@@ -1,5 +1,5 @@
1
- import { UploadOptions } from './upload.js';
2
1
  import type { Compiler } from 'webpack';
2
+ import type { UploadOptions } from './upload.js';
3
3
  import type { S3ClientOptions } from './s3-client.js';
4
4
  interface S3UploadPluginOptions {
5
5
  include?: Rule | Rule[];
@@ -13,7 +13,6 @@ class S3UploadPlugin {
13
13
  }
14
14
  apply(compiler) {
15
15
  compiler.hooks.done.tapPromise('S3UploadPlugin', async ({ compilation }) => {
16
- var _a;
17
16
  let fileNames = Object.keys(compilation.assets);
18
17
  if (this.options.additionalPattern) {
19
18
  const additionallFiles = fast_glob_1.default.sync(this.options.additionalPattern, {
@@ -29,7 +28,10 @@ class S3UploadPlugin {
29
28
  await (0, upload_js_1.uploadFiles)(fileNames, {
30
29
  s3: this.options.s3ClientOptions,
31
30
  compress: this.options.compress,
32
- options: Object.assign(Object.assign({}, this.options.s3UploadOptions), { sourcePath: (_a = compilation.outputOptions.path) !== null && _a !== void 0 ? _a : '' }),
31
+ options: {
32
+ ...this.options.s3UploadOptions,
33
+ sourcePath: compilation.outputOptions.path ?? '',
34
+ },
33
35
  });
34
36
  }
35
37
  catch (e) {
@@ -19,7 +19,7 @@ class TempDataUtils {
19
19
  }
20
20
  }
21
21
  saveSettings(newSettings = {}) {
22
- this.state = Object.assign(Object.assign({}, this.state), newSettings);
22
+ this.state = { ...this.state, ...newSettings };
23
23
  if (fs_1.default.existsSync(tempDataPath)) {
24
24
  fs_1.default.unlinkSync(tempDataPath);
25
25
  }
@@ -10,7 +10,7 @@ function formatDiagnosticBrief(ts, diagnostic, host) {
10
10
  let output = '';
11
11
  if (diagnostic.file) {
12
12
  const { file, start } = diagnostic;
13
- output += formatLocation(file, start !== null && start !== void 0 ? start : 0);
13
+ output += formatLocation(file, start ?? 0);
14
14
  output += ' - ';
15
15
  }
16
16
  output += categoryColor(diagnostic.category)(ts.DiagnosticCategory[diagnostic.category]);
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.createTransformPathsToLocalModules = void 0;
27
27
  const path = __importStar(require("path"));
28
+ const semver = __importStar(require("semver"));
28
29
  function createTransformPathsToLocalModules(ts) {
29
30
  function resolveModule(module, sourceFileName, options) {
30
31
  if (module.startsWith('.')) {
@@ -71,14 +72,14 @@ function createTransformPathsToLocalModules(ts) {
71
72
  const resolvedPath = resolveModule(modulePath, sourceFile.fileName, options);
72
73
  if (resolvedPath) {
73
74
  if (ts.isImportDeclaration(node)) {
74
- const newStatement = context.factory.updateImportDeclaration(node, node.decorators, node.modifiers, node.importClause, context.factory.createStringLiteral(resolvedPath), node.assertClause);
75
- ts.setSourceMapRange(newStatement, ts.getSourceMapRange(node));
76
- return newStatement;
75
+ const newNode = updateImportDeclaration(ts, node, context, resolvedPath);
76
+ ts.setSourceMapRange(newNode, ts.getSourceMapRange(node));
77
+ return newNode;
77
78
  }
78
79
  if (ts.isExportDeclaration(node)) {
79
- const newStatement = context.factory.updateExportDeclaration(node, node.decorators, node.modifiers, node.isTypeOnly, node.exportClause, context.factory.createStringLiteral(resolvedPath), node.assertClause);
80
- ts.setSourceMapRange(newStatement, ts.getSourceMapRange(node));
81
- return newStatement;
80
+ const newNode = updateExportDeclaration(ts, node, context, resolvedPath);
81
+ ts.setSourceMapRange(newNode, ts.getSourceMapRange(node));
82
+ return newNode;
82
83
  }
83
84
  if (isDynamicImport(node) || isRequire(node)) {
84
85
  const newStatement = context.factory.updateCallExpression(node, node.expression, node.typeArguments, context.factory.createNodeArray([
@@ -88,7 +89,7 @@ function createTransformPathsToLocalModules(ts) {
88
89
  return newStatement;
89
90
  }
90
91
  if (ts.isImportTypeNode(node)) {
91
- const newNode = context.factory.updateImportTypeNode(node, context.factory.createLiteralTypeNode(context.factory.createStringLiteral(resolvedPath)), node.qualifier, node.typeArguments, node.isTypeOf);
92
+ const newNode = updateImportTypeNode(ts, node, context, resolvedPath);
92
93
  ts.setSourceMapRange(newNode, ts.getSourceMapRange(node));
93
94
  return newNode;
94
95
  }
@@ -112,3 +113,34 @@ function createTransformPathsToLocalModules(ts) {
112
113
  };
113
114
  }
114
115
  exports.createTransformPathsToLocalModules = createTransformPathsToLocalModules;
116
+ function updateImportDeclaration(ts, node, context, resolvedPath) {
117
+ if (semver.lt(ts.version, '5.0')) {
118
+ // for versions before 5.0
119
+ return context.factory.updateImportDeclaration(node,
120
+ // @ts-expect-error
121
+ node.decorators, node.modifiers, node.importClause, context.factory.createStringLiteral(resolvedPath),
122
+ // @ts-expect-error
123
+ node.assertClause);
124
+ }
125
+ return context.factory.updateImportDeclaration(node, node.modifiers, node.importClause, context.factory.createStringLiteral(resolvedPath), node.assertClause);
126
+ }
127
+ function updateExportDeclaration(ts, node, context, resolvedPath) {
128
+ if (semver.lt(ts.version, '5.0')) {
129
+ // for versions before 5.0
130
+ return context.factory.updateExportDeclaration(node,
131
+ // @ts-expect-error
132
+ node.decorators, node.modifiers, node.isTypeOnly, node.exportClause, context.factory.createStringLiteral(resolvedPath),
133
+ // @ts-expect-error
134
+ node.assertClause);
135
+ }
136
+ return context.factory.updateExportDeclaration(node, node.modifiers, node.isTypeOnly, node.exportClause, context.factory.createStringLiteral(resolvedPath), node.assertClause);
137
+ }
138
+ function updateImportTypeNode(ts, node, context, resolvedPath) {
139
+ if (semver.lt(ts.version, '5.0')) {
140
+ // for versions before 5.0
141
+ return context.factory.updateImportTypeNode(node, context.factory.createLiteralTypeNode(context.factory.createStringLiteral(resolvedPath)),
142
+ // @ts-expect-error
143
+ node.qualifier, node.typeArguments, node.isTypeOf);
144
+ }
145
+ return context.factory.updateImportTypeNode(node, context.factory.createLiteralTypeNode(context.factory.createStringLiteral(resolvedPath)), node.assertions, node.qualifier, node.typeArguments, node.isTypeOf);
146
+ }
@@ -14,7 +14,12 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
14
14
  getCurrentDirectory: ts.sys.getCurrentDirectory,
15
15
  getNewLine: () => ts.sys.newLine,
16
16
  };
17
- const host = ts.createWatchCompilerHost(configPath, Object.assign({ noEmitOnError: false, inlineSourceMap: enableSourceMap, inlineSources: enableSourceMap }, (enableSourceMap ? { sourceMap: false } : undefined)), ts.sys, createProgram, reportDiagnostic, reportWatchStatusChanged);
17
+ const host = ts.createWatchCompilerHost(configPath, {
18
+ noEmitOnError: false,
19
+ inlineSourceMap: enableSourceMap,
20
+ inlineSources: enableSourceMap,
21
+ ...(enableSourceMap ? { sourceMap: false } : undefined),
22
+ }, ts.sys, createProgram, reportDiagnostic, reportWatchStatusChanged);
18
23
  host.readFile = (0, utils_1.displayFilename)(host.readFile, 'Reading', logger);
19
24
  (0, utils_1.onHostEvent)(host, 'createProgram', () => {
20
25
  logger.verbose("We're about to create the program");
@@ -34,7 +39,7 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
34
39
  });
35
40
  logger.verbose('Emit completed!');
36
41
  }, () => {
37
- onAfterFilesEmitted === null || onAfterFilesEmitted === void 0 ? void 0 : onAfterFilesEmitted();
42
+ onAfterFilesEmitted?.();
38
43
  });
39
44
  // `createWatchProgram` creates an initial program, watches files, and updates
40
45
  // the program over time.