@gravity-ui/app-builder 0.8.5 → 0.8.7

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.
@@ -12,6 +12,7 @@ import type { ForkTsCheckerWebpackPluginOptions } from 'fork-ts-checker-webpack-
12
12
  import type { Options as StatoscopeOptions } from '@statoscope/webpack-plugin';
13
13
  import type { SentryWebpackPluginOptions } from '@sentry/webpack-plugin';
14
14
  import type { WebpackMode } from '../webpack/config';
15
+ import type { UploadOptions } from '../s3-upload/upload';
15
16
  export interface Entities<T> {
16
17
  data: Record<string, T>;
17
18
  keys: string[];
@@ -187,12 +188,13 @@ export interface ClientConfig {
187
188
  configType: `${WebpackMode}`;
188
189
  }) => Babel.TransformOptions | Promise<Babel.TransformOptions>;
189
190
  }
190
- interface CdnUploadConfig {
191
+ export interface CdnUploadConfig {
191
192
  bucket: string;
192
193
  prefix?: string;
193
194
  region?: string;
194
195
  endpoint?: string;
195
196
  compress?: boolean;
197
+ cacheControl?: UploadOptions['cacheControl'];
196
198
  /**
197
199
  * pattern for additional files in build that need to be loaded to CDN
198
200
  */
@@ -10,6 +10,7 @@ export declare function getS3Client(options: S3ClientOptions): {
10
10
  interface UploadOptionsCommon {
11
11
  expires?: PutObjectCommandInput['Expires'];
12
12
  meta?: PutObjectCommandInput['Metadata'];
13
+ cacheControl?: PutObjectCommandInput['CacheControl'];
13
14
  }
14
15
  export interface S3UploadDirOptions extends UploadOptionsCommon {
15
16
  concurrency?: number;
@@ -64,6 +64,9 @@ function getS3Client(options) {
64
64
  if (expires) {
65
65
  params.Metadata = { ...params.Metadata, Expires: expires.toString() };
66
66
  }
67
+ if (opts.cacheControl) {
68
+ params.CacheControl = opts.cacheControl;
69
+ }
67
70
  return s3Client.send(new client_s3_1.PutObjectCommand(params));
68
71
  },
69
72
  uploadDir(bucket, dirPath, keyPrefix = '', { concurrency = 512, ...opts } = {}) {
@@ -5,6 +5,7 @@ export interface UploadOptions {
5
5
  sourcePath: string;
6
6
  targetPath?: string;
7
7
  existsBehavior?: 'overwrite' | 'throw' | 'ignore';
8
+ cacheControl?: string | ((filename: string) => string);
8
9
  }
9
10
  export interface UploadFilesOptions {
10
11
  s3: S3ClientOptions;
@@ -75,7 +75,12 @@ function uploadFiles(files, config) {
75
75
  }
76
76
  }
77
77
  }
78
- return uploadFile(options.bucket, sourceFilePath, targetFilePath)
78
+ const cacheControl = typeof options.cacheControl === 'function'
79
+ ? options.cacheControl(targetFilePath)
80
+ : options.cacheControl;
81
+ return uploadFile(options.bucket, sourceFilePath, targetFilePath, {
82
+ cacheControl,
83
+ })
79
84
  .then(() => {
80
85
  log.message(`Uploaded ${relativeFilePath} => ${targetFilePath}`);
81
86
  return relativeFilePath;
@@ -7,7 +7,7 @@ interface S3UploadPluginOptions {
7
7
  exclude?: Rule | Rule[];
8
8
  compress?: boolean;
9
9
  s3ClientOptions: S3ClientOptions;
10
- s3UploadOptions: Pick<UploadOptions, 'bucket' | 'targetPath' | 'existsBehavior'>;
10
+ s3UploadOptions: Pick<UploadOptions, 'bucket' | 'targetPath' | 'existsBehavior' | 'cacheControl'>;
11
11
  additionalPattern?: string | string[];
12
12
  logger?: Logger;
13
13
  }
@@ -709,6 +709,7 @@ function configurePlugins(options) {
709
709
  s3UploadOptions: {
710
710
  bucket: cdn.bucket,
711
711
  targetPath: cdn.prefix,
712
+ cacheControl: cdn.cacheControl,
712
713
  },
713
714
  additionalPattern: cdn.additionalPattern,
714
715
  logger: options.logger,
@@ -20,7 +20,7 @@ function generateWorkerLoader(url) {
20
20
  const publicPath = __webpack_public_path__;
21
21
  const workerPublicPath = publicPath.match(/^https?:\/\//)
22
22
  ? publicPath
23
- : new URL(publicPath, window.location.href).toString();
23
+ : new URL(publicPath, window.location.origin).toString();
24
24
  const objectURL = URL.createObjectURL(new Blob([
25
25
  [
26
26
  `self.__PUBLIC_PATH__ = ${JSON.stringify(workerPublicPath)}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "description": "Develop and build your React client-server projects, powered by typescript and webpack",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",