Skip to content

Commit 796e410

Browse files
authored
fix(build): import 'subresources' after setting puppeteer env (#186)
1 parent 60b3790 commit 796e410

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/build.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as path from "path";
22
import { copyFile, mkdir, readFile, writeFile, unlink } from "fs/promises";
33
import fetch from "node-fetch";
4-
import { getAllSubResources, ResourceType } from "subresources";
54
import { env, exit, setOutput, sh, unique } from "./utils.js";
65
import { deepEqual, StaticServer } from "./utils.js";
76
import { PUPPETEER_ENV } from "./constants.js";
7+
import type { ResourceType } from "subresources";
88

99
import { BasicBuildOptions as BasicBuildOptions_ } from "./prepare-build.js";
1010
import { ProcessedInput } from "./prepare.js";
@@ -172,16 +172,18 @@ async function findAssetsToCopy(source: Input["source"]) {
172172
let localAssets: string[] = [];
173173
let remoteAssets: URL[] = [];
174174

175+
Object.assign(process.env, PUPPETEER_ENV);
176+
const {
177+
getAllSubResources,
178+
}: typeof import("subresources") = require("subresources");
179+
175180
const server = await new StaticServer().start();
176181

177182
const isLocalAsset = (url: URL) => url.origin === server.url.origin;
178183
const remoteAssetRules: ((url: URL, type: ResourceType) => boolean)[] = [
179184
(url: URL) => url.origin === "https://user-images.githubusercontent.com",
180185
];
181186

182-
process.env["PUPPETEER_EXECUTABLE_PATH"] =
183-
PUPPETEER_ENV.PUPPETEER_EXECUTABLE_PATH;
184-
185187
const mainPage = urlToPage(new URL(tmpOutputFile(source), server.url));
186188
const pages = new Set([mainPage]);
187189
for (const page of pages) {

0 commit comments

Comments
 (0)