|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import path from 'node:path'; |
| 7 | +import { pathToFileURL } from 'node:url'; |
7 | 8 |
|
8 | 9 | import globToRegExp from 'glob-to-regexp'; |
9 | 10 |
|
@@ -35,16 +36,20 @@ export async function loadStaticPublisherRcFile(): Promise<StaticPublishRc> { |
35 | 36 |
|
36 | 37 | const configFile = './static-publish.rc.js'; |
37 | 38 |
|
| 39 | + const configFilePath = path.resolve(configFile); |
38 | 40 | try { |
39 | | - const filePath = path.resolve(configFile); |
40 | | - configRaw = (await import(filePath)).default; |
41 | | - } catch { |
42 | | - // |
| 41 | + configRaw = (await import(pathToFileURL(configFilePath).href)).default; |
| 42 | + } catch (ex) { |
| 43 | + throw new LoadConfigError(configFile, [ |
| 44 | + `Unable to load ${configFilePath}`, |
| 45 | + String(ex), |
| 46 | + ]); |
43 | 47 | } |
44 | 48 |
|
45 | 49 | if (configRaw == null) { |
46 | 50 | throw new LoadConfigError(configFile, [ |
47 | | - 'Unable to load ' + configFile, |
| 51 | + `Unable to load ${configFilePath}`, |
| 52 | + `default export does not exist or is null.` |
48 | 53 | ]); |
49 | 54 | } |
50 | 55 |
|
@@ -128,16 +133,20 @@ export async function loadPublishContentConfigFile(configFile: string): Promise< |
128 | 133 |
|
129 | 134 | let configRaw; |
130 | 135 |
|
| 136 | + const configFilePath = path.resolve(configFile); |
131 | 137 | try { |
132 | | - const filePath = path.resolve(configFile); |
133 | | - configRaw = (await import(filePath)).default; |
134 | | - } catch { |
135 | | - // |
| 138 | + configRaw = (await import(pathToFileURL(configFilePath).href)).default; |
| 139 | + } catch (ex) { |
| 140 | + throw new LoadConfigError(configFile, [ |
| 141 | + `Unable to load ${configFilePath}`, |
| 142 | + String(ex), |
| 143 | + ]); |
136 | 144 | } |
137 | 145 |
|
138 | 146 | if (configRaw == null) { |
139 | 147 | throw new LoadConfigError(configFile, [ |
140 | | - 'Unable to load ' + configFile, |
| 148 | + `Unable to load ${configFilePath}`, |
| 149 | + `default export does not exist or is null.` |
141 | 150 | ]); |
142 | 151 | } |
143 | 152 |
|
|
0 commit comments