* @param {string} projectDir a project directory * @returns {Promise<EXPECTED_ANY | undefined>} webpack options
(projectDir)
| 50 | * @returns {Promise<EXPECTED_ANY | undefined>} webpack options |
| 51 | */ |
| 52 | async function loadConfiguration(projectDir) { |
| 53 | const paths = [ |
| 54 | path.join(projectDir, "webpack.config.js"), |
| 55 | path.join(projectDir, "webpack.config.mjs"), |
| 56 | path.join(projectDir, "webpack.config.cjs") |
| 57 | ]; |
| 58 | |
| 59 | let options; |
| 60 | |
| 61 | for (const path of paths) { |
| 62 | if (!fs.existsSync(path)) { |
| 63 | continue; |
| 64 | } |
| 65 | |
| 66 | if (nodeVersion < 18) { |
| 67 | try { |
| 68 | options = require(path); |
| 69 | return options; |
| 70 | } catch (_err) { |
| 71 | // Nothing |
| 72 | } |
| 73 | |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | try { |
| 78 | options = await dynamicImport(path); |
| 79 | return options.default; |
| 80 | } catch (_err) { |
| 81 | try { |
| 82 | options = require(path); |
| 83 | } catch (_err) { |
| 84 | // Nothing |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | return options; |
| 90 | } |
| 91 | |
| 92 | describe("Examples", () => { |
| 93 | const basePath = path.join(__dirname, "..", "examples"); |
no test coverage detected