@financial-times/dotcom-server-asset-loader 11.3.0 → 12.0.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.
@@ -1,7 +1,7 @@
1
1
  export interface AssetLoaderOptions {
2
2
  /**
3
3
  * The name of the asset manifest file
4
- * @default "manifest.json"
4
+ * @default "assets-manifest.json"
5
5
  */
6
6
  manifestFileName?: string;
7
7
  /**
@@ -25,18 +25,20 @@ export interface AssetLoaderOptions {
25
25
  [asset: string]: string;
26
26
  };
27
27
  }
28
- declare type TEntrypoint = {
28
+ type TEntrypoint = {
29
29
  [type: string]: string[];
30
30
  };
31
- declare type TEntrypoints = {
31
+ type TEntrypoints = {
32
32
  entrypoints?: {
33
- [name: string]: TEntrypoint;
33
+ [name: string]: {
34
+ assets: TEntrypoint;
35
+ };
34
36
  };
35
37
  };
36
- declare type TFiles = {
38
+ type TFiles = {
37
39
  [name: string]: string;
38
40
  };
39
- export declare type TManifest = TEntrypoints & TFiles;
41
+ export type TManifest = TEntrypoints & TFiles;
40
42
  export declare class AssetLoader {
41
43
  options: AssetLoaderOptions;
42
44
  manifest: TManifest;
@@ -10,7 +10,7 @@ const loadFile_1 = require("./helpers/loadFile");
10
10
  const loadManifest_1 = require("./helpers/loadManifest");
11
11
  const defaultOptions = {
12
12
  publicPath: '/',
13
- manifestFileName: 'manifest.json',
13
+ manifestFileName: 'assets-manifest.json',
14
14
  fileSystemPath: path_1.default.resolve('./public'),
15
15
  cacheFileContents: false
16
16
  };
@@ -19,7 +19,7 @@ class AssetLoader {
19
19
  this.options = { ...defaultOptions, ...userOptions };
20
20
  this.manifest =
21
21
  this.options.manifest ||
22
- loadManifest_1.loadManifest(path_1.default.resolve(this.options.fileSystemPath, this.options.manifestFileName));
22
+ (0, loadManifest_1.loadManifest)(path_1.default.resolve(this.options.fileSystemPath, this.options.manifestFileName));
23
23
  }
24
24
  getHashedAsset(asset) {
25
25
  if (this.manifest.hasOwnProperty(asset)) {
@@ -30,7 +30,7 @@ class AssetLoader {
30
30
  }
31
31
  }
32
32
  getFileContents(asset) {
33
- return loadFile_1.loadFile(this.getFileSystemPath(asset), this.options.cacheFileContents);
33
+ return (0, loadFile_1.loadFile)(this.getFileSystemPath(asset), this.options.cacheFileContents);
34
34
  }
35
35
  getFileSystemPath(asset) {
36
36
  return this.formatFileSystemPath(this.getHashedAsset(asset));
@@ -42,7 +42,7 @@ class AssetLoader {
42
42
  // File name prefix methods
43
43
  //
44
44
  formatPublicURL(hashedAsset) {
45
- return url_join_1.default(this.options.publicPath, hashedAsset);
45
+ return (0, url_join_1.default)(this.options.publicPath, hashedAsset);
46
46
  }
47
47
  formatFileSystemPath(hashedAsset) {
48
48
  return path_1.default.join(this.options.fileSystemPath, hashedAsset);
@@ -52,7 +52,7 @@ class AssetLoader {
52
52
  //
53
53
  getFilesFor(entrypoint) {
54
54
  if (this.manifest.entrypoints && this.manifest.entrypoints[entrypoint]) {
55
- return this.manifest.entrypoints[entrypoint];
55
+ return this.manifest.entrypoints[entrypoint].assets;
56
56
  }
57
57
  else {
58
58
  throw Error(`Couldn't find entrypoint "${entrypoint}" in manifest`);
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadFile = void 0;
6
+ exports.loadFile = loadFile;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  // Avoid hitting the disk each time a file is requested and instead
9
9
  // hold the file contents in memory for the lifecycle of the app
@@ -21,4 +21,3 @@ function loadFile(fullPath, cache = false) {
21
21
  return fileAsString;
22
22
  }
23
23
  }
24
- exports.loadFile = loadFile;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadManifest = void 0;
3
+ exports.loadManifest = loadManifest;
4
4
  const loadFile_1 = require("./loadFile");
5
5
  function loadManifest(filePath) {
6
- const manifest = loadFile_1.loadFile(filePath);
6
+ const manifest = (0, loadFile_1.loadFile)(filePath);
7
7
  return JSON.parse(manifest);
8
8
  }
9
- exports.loadManifest = loadManifest;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];