<file_sep>const path = require('path');

exports = module.exports = function () {
  this.register('script-dep-fix', function scriptDepFix (parsed, isNPM) {
    let code = parsed.code;
    let fixPos = 0;
    parsed.parser.deps.forEach((dep, i) => {
      let depMod = parsed.depModules[i];
      let moduleId = (typeof depMod === 'object') ? depMod.id : depMod;
      let replaceMent = '';
      if (isNPM) {
        replaceMent = `__wepy_require(${moduleId})`;
      } else {
        if (typeof depMod === 'object' && depMod.type !== 'npm') {
          let relativePath = path.relative(path.dirname(parsed.file), depMod.file);
          replaceMent = `require('${relativePath}')`;
        } else {
          if (typeof moduleId === 'number') {
            let npmfile = path.join(this.context, this.options.src, 'vendor.js');
            let relativePath = path.relative(path.dirname(parsed.file), npmfile);
            replaceMent = `require('${relativePath}')(${moduleId})`;
          } else if (depMod && depMod.sfc) {
            let relativePath = path.relative(path.dirname(parsed.file), depMod.file);
            let reg = new RegExp('\\' + this.options.wpyExt + '$', 'i');
            relativePath = relativePath.replace(reg, '.js');
            replaceMent = `require('${relativePath}')`;
          } else if (depMod === false) {
            replaceMent = '{}';
          } else {
            replaceMent = `require('${dep.module}')`;
          }
        }
      }
      parsed.source.replace(dep.expr.start, dep.expr.end - 1, replaceMent);
    });
  });
}
<file_sep>import { patchMixins, patchData, patchMethods, patchLifecycle, patchProps } from './init/index';

function page (option = {}, rel) {

  let pageConfig = {};

  patchMixins(pageConfig, option, option.mixins);

  if (option.properties) {
    pageConfig.properties = option.properties;
    if (option.props) {
      console.warn(`props will be ignore, if properties is set`);
    }
  } else if (option.props) {
    patchProps(pageConfig, option.props);
  }

  patchMethods(pageConfig, option.methods);

  patchData(pageConfig, option.data);

  patchLifecycle(pageConfig, option, rel);

  return Component(pageConfig);
}


export default page;
<file_sep>const path = require('path');
const loaderUtils = require('loader-utils');

const pluginRE = /plugin\:/;


exports = module.exports = function () {
  this.register('wepy-parser-config', function (rst, ctx) {
    let configString = rst.content.replace(/^\n*/, '').replace(/\n*$/, '');
    configString = configString || '{}';
    let config = null;
    try {
      let fn = new Function('return ' + configString);
      config = fn();
    } catch (e) {
      return Promise.reject(`invalid json: ${configString}`);
    }
    config.component = true;
    config.usingComponents = config.usingComponents || {};

    let componentKeys = Object.keys(config.usingComponents);

    if (componentKeys.length === 0) {
      return Promise.resolve(config);
    }

    // Getting resolved path for usingComponents

    let resolved = Object.keys(config.usingComponents).map(comp => {
      const url = config.usingComponents[comp];
      if (pluginRE.test(url)) {
        return Promise.resolve([comp, url]);
      }
      const moduleRequest = loaderUtils.urlToRequest(url, url.charAt(0) === '/' ? '' : null);
      return this.resolvers.normal.resolve({}, path.dirname(ctx.file), moduleRequest, {}).then(rst => {
        let parsed = path.parse(rst.path);
        let fullpath = path.join(parsed.dir, parsed.name); // remove file extention
        let relative = path.relative(path.dirname(ctx.file), fullpath);
        return [comp, relative];
      });
    });

    return Promise.all(resolved).then(rst => {
      rst.forEach(item => {
        config.usingComponents[item[0]] = item[1];
      });
      return config;
    });
  });
}
