packages/okam-build/lib/processor/json/component-json.js
function addComponentSameNameFiles(scriptFile, options) {
    const {dirname: currDir, path: relPath} = scriptFile;
    const scriptFileName = getFileName(relPath);
    // fullPath
    let filePathBase = path.join(currDir, scriptFileName);

    const {
        root,
        addFile,
        sourceDir,
        getFileByFullPath,
        appType,
        wx2swan,
        componentExtname,
        logger
    } = options;

    let compFilesInfo = getCompFilesInfoByAppType(
        filePathBase,
        {
            appType,
            wx2swan,
            componentExtname,
            compileContext: options
        }
    );

    let {componentType, missingMustFileExtnames, fileExtnameMap} = compFilesInfo;
    let jsonFile;
    if (!isFileInSourceDir(scriptFile.path, sourceDir)) {
        Object.keys(fileExtnameMap || {}).forEach(k => {
            let fileObj = addFile(fileExtnameMap[k]);

            if (fileObj.isJson) {
                jsonFile = fileObj;
            }
        });
    }
    else {
        jsonFile = getFileByFullPath(`${filePathBase}.json`);
        if (jsonFile && !jsonFile.owner) {
            Object.keys(fileExtnameMap || {}).forEach(k => {
                addFile(fileExtnameMap[k]);
            });
        }
    }

    // all must have js script except quick
    if (componentType && scriptFile) {
        scriptFile[componentType] = true;
    }

    if (jsonFile) {
        jsonFile.isComponentConfig = true;
        jsonFile.component = scriptFile;
        addFile(fileExtnameMap.json);
    }

    if (missingMustFileExtnames.length) {
        let compFile = getRelative(filePathBase, root);
        missingMustFileExtnames.forEach(ext => {
            logger.error(`missing component file: 「${compFile}.${ext}」.`);
        });
    }
}
function addComponentSameNameFiles(scriptFile, options) {
    const {dirname: currDir, path: relPath} = scriptFile;
    const scriptFileName = getFileName(relPath);
    // fullPath
    let filePathBase = path.join(currDir, scriptFileName);

    const {
        root,
        addFile,
        sourceDir,
        getFileByFullPath,
        appType,
        wx2swan,
        componentExtname,
        logger
    } = options;

    let compFilesInfo = getCompFilesInfoByAppType(
        filePathBase,
        {
            appType,
            wx2swan,
            componentExtname,
            compileContext: options
        }
    );

    let {componentType, missingMustFileExtnames, fileExtnameMap} = compFilesInfo;
    let jsonFile;
    if (!isFileInSourceDir(scriptFile.path, sourceDir)) {
        Object.keys(fileExtnameMap || {}).forEach(k => {
            let fileObj = addFile(fileExtnameMap[k]);

            if (fileObj.isJson) {
                jsonFile = fileObj;
            }
        });
    }
    else {
        jsonFile = getFileByFullPath(`${filePathBase}.json`);
        if (jsonFile && !jsonFile.owner) {
            Object.keys(fileExtnameMap || {}).forEach(k => {
                addFile(fileExtnameMap[k]);
            });
        }
    }

    // all must have js script except quick
    if (componentType && scriptFile) {
        scriptFile[componentType] = true;
    }

    if (jsonFile) {
        jsonFile.isComponentConfig = true;
        jsonFile.component = scriptFile;
        addFile(fileExtnameMap.json);
    }

    if (missingMustFileExtnames.length) {
        let compFile = getRelative(filePathBase, root);
        missingMustFileExtnames.forEach(ext => {
            logger.error(`missing component file: 「${compFile}.${ext}」.`);
        });
    }
}
function addComponentSameNameFiles ( scriptFile , options ) { const { dirname : currDir , path : relPath } = scriptFile ; const scriptFileName = getFileName ( relPath ) ; // fullPath let filePathBase = path . join ( currDir , scriptFileName ) ; const { root , addFile , sourceDir , getFileByFullPath , appType , wx2swan , componentExtname , logger } = options ; let compFilesInfo = getCompFilesInfoByAppType ( filePathBase , { appType , wx2swan , componentExtname , compileContext : options } ) ; let { componentType , missingMustFileExtnames , fileExtnameMap } = compFilesInfo ; let jsonFile ; if ( ! isFileInSourceDir ( scriptFile . path , sourceDir ) ) { Object . keys ( fileExtnameMap || { } ) . forEach ( k => { let fileObj = addFile ( fileExtnameMap [ k ] ) ; if ( fileObj . isJson ) { jsonFile = fileObj ; } } ) ; } else { jsonFile = getFileByFullPath ( ` ${ filePathBase } ` ) ; if ( jsonFile && ! jsonFile . owner ) { Object . keys ( fileExtnameMap || { } ) . forEach ( k => { addFile ( fileExtnameMap [ k ] ) ; } ) ; } } // all must have js script except quick if ( componentType && scriptFile ) { scriptFile [ componentType ] = true ; } if ( jsonFile ) { jsonFile . isComponentConfig = true ; jsonFile . component = scriptFile ; addFile ( fileExtnameMap . json ) ; } if ( missingMustFileExtnames . length ) { let compFile = getRelative ( filePathBase , root ) ; missingMustFileExtnames . forEach ( ext => { logger . error ( ` co mpFile}. $ ex t}」 . } ) ; } }
Add component same name files

@inner
@param {Object} scriptFile the component script file
@param {Object} options the process options
Add component same name files