mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
feat: support mjs external configs
This commit is contained in:
@ -3,6 +3,7 @@ import fs from 'fs';
|
||||
|
||||
import { getAllDependencies, getDependencyPath } from './dependencies';
|
||||
import { clearCurrentPlugin, setCurrentPlugin } from '../index';
|
||||
import { tryRequireThenImport } from './dynamicImports';
|
||||
import { info, warn } from './log';
|
||||
import * as lib from '../index';
|
||||
|
||||
@ -17,13 +18,20 @@ export async function applyExternalConfigs() {
|
||||
continue;
|
||||
}
|
||||
|
||||
const configPath = path.join(packagePath, 'nativescript.webpack.js');
|
||||
const configPaths = [
|
||||
path.join(packagePath, 'nativescript.webpack.mjs'),
|
||||
path.join(packagePath, 'nativescript.webpack.js'),
|
||||
];
|
||||
|
||||
if (fs.existsSync(configPath)) {
|
||||
const configPath = configPaths.find((_configPath) =>
|
||||
fs.existsSync(_configPath)
|
||||
);
|
||||
|
||||
if (configPath) {
|
||||
info(`Discovered config: ${configPath}`);
|
||||
setCurrentPlugin(dependency);
|
||||
try {
|
||||
const externalConfig = require(configPath);
|
||||
const externalConfig = await tryRequireThenImport(configPath);
|
||||
|
||||
if (typeof externalConfig === 'function') {
|
||||
info('Applying external config...');
|
||||
|
Reference in New Issue
Block a user