|
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 |
|
@@ -46,16 +47,20 @@ export async function loadStaticPublisherRcFile(): Promise<StaticPublishRc> { |
46 | 47 |
|
47 | 48 | const configFile = './static-publish.rc.js'; |
48 | 49 |
|
| 50 | + const configFilePath = path.resolve(configFile); |
49 | 51 | try { |
50 | | - const filePath = path.resolve(configFile); |
51 | | - configRaw = (await import(filePath)).default; |
52 | | - } catch { |
53 | | - // |
| 52 | + configRaw = (await import(pathToFileURL(configFilePath).href)).default; |
| 53 | + } catch (ex) { |
| 54 | + throw new LoadConfigError(configFile, [ |
| 55 | + `Unable to load ${configFilePath}`, |
| 56 | + String(ex), |
| 57 | + ]); |
54 | 58 | } |
55 | 59 |
|
56 | 60 | if (configRaw == null) { |
57 | 61 | throw new LoadConfigError(configFile, [ |
58 | | - 'Unable to load ' + configFile, |
| 62 | + `Unable to load ${configFilePath}`, |
| 63 | + `default export does not exist or is null.` |
59 | 64 | ]); |
60 | 65 | } |
61 | 66 |
|
@@ -143,16 +148,20 @@ export async function loadPublishContentConfigFile(configFile: string): Promise< |
143 | 148 |
|
144 | 149 | let configRaw; |
145 | 150 |
|
| 151 | + const configFilePath = path.resolve(configFile); |
146 | 152 | try { |
147 | | - const filePath = path.resolve(configFile); |
148 | | - configRaw = (await import(filePath)).default; |
149 | | - } catch { |
150 | | - // |
| 153 | + configRaw = (await import(pathToFileURL(configFilePath).href)).default; |
| 154 | + } catch (ex) { |
| 155 | + throw new LoadConfigError(configFile, [ |
| 156 | + `Unable to load ${configFilePath}`, |
| 157 | + String(ex), |
| 158 | + ]); |
151 | 159 | } |
152 | 160 |
|
153 | 161 | if (configRaw == null) { |
154 | 162 | throw new LoadConfigError(configFile, [ |
155 | | - 'Unable to load ' + configFile, |
| 163 | + `Unable to load ${configFilePath}`, |
| 164 | + `default export does not exist or is null.` |
156 | 165 | ]); |
157 | 166 | } |
158 | 167 |
|
|
0 commit comments