How to use the umi-utils.compatDirname function in umi-utils

To help you get started, we’ve selected a few umi-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github umijs / umi / packages / umi-test / src / transformers / jsTransformer.js View on Github external
[
      require.resolve('babel-plugin-module-resolver'),
      {
        alias: {
          // Projects don't need to install react, react-dom and enzyme
          react: compatDirname(
            'react/package',
            cwd,
            dirname(require.resolve('react/package.json')),
          ),
          'react-dom': compatDirname(
            'react-dom/package',
            cwd,
            dirname(require.resolve('react-dom/package.json')),
          ),
          enzyme: compatDirname(
            'enzyme/package.json',
            cwd,
            dirname(require.resolve('enzyme/package.json')),
          ),
          'enzyme-adapter-react-16': compatDirname(
            'enzyme-adapter-react-16/package.json',
            cwd,
            dirname(require.resolve('enzyme-adapter-react-16/package.json')),
          ),
        },
      },
      'umi-test',
    ],
  ],
});
github umijs / umi / packages / umi-test / src / transformers / jsTransformer.js View on Github external
require.resolve('@babel/preset-typescript'),
    [
      require.resolve('babel-preset-umi'),
      {
        transformRuntime: false,
        // ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
      },
    ],
  ],
  plugins: [
    [
      require.resolve('babel-plugin-module-resolver'),
      {
        alias: {
          // Projects don't need to install react, react-dom and enzyme
          react: compatDirname(
            'react/package',
            cwd,
            dirname(require.resolve('react/package.json')),
          ),
          'react-dom': compatDirname(
            'react-dom/package',
            cwd,
            dirname(require.resolve('react-dom/package.json')),
          ),
          enzyme: compatDirname(
            'enzyme/package.json',
            cwd,
            dirname(require.resolve('enzyme/package.json')),
          ),
          'enzyme-adapter-react-16': compatDirname(
            'enzyme-adapter-react-16/package.json',
github ddnlink / ddn / packages / ddn-test / src / transformers / jsTransformer.js View on Github external
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
      },
    ],
  ],
  plugins: [
    [
      require.resolve('babel-plugin-module-resolver'),
      {
        alias: {
          // Projects don't need to install react, react-dom and enzyme
          react: compatDirname(
            'react/package',
            cwd,
            dirname(require.resolve('react/package.json')),
          ),
          'react-dom': compatDirname(
            'react-dom/package',
            cwd,
            dirname(require.resolve('react-dom/package.json')),
          ),
          enzyme: compatDirname(
            'enzyme/package.json',
            cwd,
            dirname(require.resolve('enzyme/package.json')),
          ),
          'enzyme-adapter-react-16': compatDirname(
            'enzyme-adapter-react-16/package.json',
            cwd,
            dirname(require.resolve('enzyme-adapter-react-16/package.json')),
          ),
        },
      },
github umijs / umi / packages / umi-test / src / transformers / jsTransformer.js View on Github external
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
      },
    ],
  ],
  plugins: [
    [
      require.resolve('babel-plugin-module-resolver'),
      {
        alias: {
          // Projects don't need to install react, react-dom and enzyme
          react: compatDirname(
            'react/package',
            cwd,
            dirname(require.resolve('react/package.json')),
          ),
          'react-dom': compatDirname(
            'react-dom/package',
            cwd,
            dirname(require.resolve('react-dom/package.json')),
          ),
          enzyme: compatDirname(
            'enzyme/package.json',
            cwd,
            dirname(require.resolve('enzyme/package.json')),
          ),
          'enzyme-adapter-react-16': compatDirname(
            'enzyme-adapter-react-16/package.json',
            cwd,
            dirname(require.resolve('enzyme-adapter-react-16/package.json')),
          ),
        },
      },
github ddnlink / ddn / packages / ddn-test / src / transformers / jsTransformer.js View on Github external
[
      require.resolve('babel-plugin-module-resolver'),
      {
        alias: {
          // Projects don't need to install react, react-dom and enzyme
          react: compatDirname(
            'react/package',
            cwd,
            dirname(require.resolve('react/package.json')),
          ),
          'react-dom': compatDirname(
            'react-dom/package',
            cwd,
            dirname(require.resolve('react-dom/package.json')),
          ),
          enzyme: compatDirname(
            'enzyme/package.json',
            cwd,
            dirname(require.resolve('enzyme/package.json')),
          ),
          'enzyme-adapter-react-16': compatDirname(
            'enzyme-adapter-react-16/package.json',
            cwd,
            dirname(require.resolve('enzyme-adapter-react-16/package.json')),
          ),
        },
      },
      'ddn-test',
    ],
  ],
});
github ddnlink / ddn / packages / ddn-test / src / transformers / jsTransformer.js View on Github external
require.resolve('@babel/preset-typescript'),
    [
      require.resolve('babel-preset-umi'),
      {
        transformRuntime: false,
        // ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
      },
    ],
  ],
  plugins: [
    [
      require.resolve('babel-plugin-module-resolver'),
      {
        alias: {
          // Projects don't need to install react, react-dom and enzyme
          react: compatDirname(
            'react/package',
            cwd,
            dirname(require.resolve('react/package.json')),
          ),
          'react-dom': compatDirname(
            'react-dom/package',
            cwd,
            dirname(require.resolve('react-dom/package.json')),
          ),
          enzyme: compatDirname(
            'enzyme/package.json',
            cwd,
            dirname(require.resolve('enzyme/package.json')),
          ),
          'enzyme-adapter-react-16': compatDirname(
            'enzyme-adapter-react-16/package.json',
github umijs / umi / packages / umi-build-dev / src / plugins / afwebpack-config / index.js View on Github external
onChange(newConfig) {
            try {
              debug(`Config ${name} changed to ${JSON.stringify(newConfig[name])}`);
            } catch (e) {} // eslint-disable-line no-empty
            if (name === 'proxy') {
              global.g_umi_reloadProxy(newConfig[name]);
            } else {
              api.service.restart(`${name} changed`);
            }
          },
          ...extraOpts,
        });
      });
  });

  const reactDir = compatDirname(
    'react/package.json',
    cwd,
    dirname(require.resolve('react/package.json')),
  );
  const reactDOMDir = compatDirname(
    'react-dom/package.json',
    cwd,
    dirname(require.resolve('react-dom/package.json')),
  );
  const reactRouterDir = dirname(require.resolve('react-router/package.json'));
  const reactRouterDOMDir = dirname(require.resolve('react-router-dom/package.json'));
  const reactRouterConfigDir = dirname(require.resolve('react-router-config/package.json'));
  api.chainWebpackConfig(webpackConfig => {
    webpackConfig.resolve.alias
      .set('react', reactDir)
      .set('react-dom', reactDOMDir)
github ddnlink / ddn / packages / ddn-test / src / transformers / jsTransformer.js View on Github external
react: compatDirname(
            'react/package',
            cwd,
            dirname(require.resolve('react/package.json')),
          ),
          'react-dom': compatDirname(
            'react-dom/package',
            cwd,
            dirname(require.resolve('react-dom/package.json')),
          ),
          enzyme: compatDirname(
            'enzyme/package.json',
            cwd,
            dirname(require.resolve('enzyme/package.json')),
          ),
          'enzyme-adapter-react-16': compatDirname(
            'enzyme-adapter-react-16/package.json',
            cwd,
            dirname(require.resolve('enzyme-adapter-react-16/package.json')),
          ),
        },
      },
      'ddn-test',
    ],
  ],
});
github umijs / umi / packages / umi-build-dev / src / plugins / afwebpack-config / index.js View on Github external
global.g_umi_reloadProxy(newConfig[name]);
            } else {
              api.service.restart(`${name} changed`);
            }
          },
          ...extraOpts,
        });
      });
  });

  const reactDir = compatDirname(
    'react/package.json',
    cwd,
    dirname(require.resolve('react/package.json')),
  );
  const reactDOMDir = compatDirname(
    'react-dom/package.json',
    cwd,
    dirname(require.resolve('react-dom/package.json')),
  );
  const reactRouterDir = dirname(require.resolve('react-router/package.json'));
  const reactRouterDOMDir = dirname(require.resolve('react-router-dom/package.json'));
  const reactRouterConfigDir = dirname(require.resolve('react-router-config/package.json'));
  api.chainWebpackConfig(webpackConfig => {
    webpackConfig.resolve.alias
      .set('react', reactDir)
      .set('react-dom', reactDOMDir)
      .set('react-router', reactRouterDir)
      .set('react-router-dom', reactRouterDOMDir)
      .set('react-router-config', reactRouterConfigDir)
      .set(
        'history',
github umijs / umi / packages / umi-build-dev / src / plugins / afwebpack-config / index.js View on Github external
api.chainWebpackConfig(webpackConfig => {
    webpackConfig.resolve.alias
      .set('react', reactDir)
      .set('react-dom', reactDOMDir)
      .set('react-router', reactRouterDir)
      .set('react-router-dom', reactRouterDOMDir)
      .set('react-router-config', reactRouterConfigDir)
      .set(
        'history',
        compatDirname(
          'umi-history/package.json',
          cwd,
          dirname(require.resolve('umi-history/package.json')),
        ),
      )
      .set('@', paths.absSrcPath)
      .set('@tmp', paths.absTmpDirPath)
      .set('@@', paths.absTmpDirPath)
      .set('umi', process.env.UMI_DIR);
  });