How to use the metro-config/src/defaults/defaults.moduleSystem function in metro-config

To help you get started, we’ve selected a few metro-config 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 Marwan01 / food-converter / node_modules / metro / src / lib / getPrependedScripts.js View on Github external
deltaBundler
  ) {
    // Get all the polyfills from the relevant option params (the
    // `getPolyfills()` method and the `polyfillModuleNames` variable).
    const polyfillModuleNames = config.serializer
      .getPolyfills({
        platform: options.platform
      })
      .concat(config.serializer.polyfillModuleNames);

    const transformOptions = _objectSpread({}, options, {
      type: "script"
    });

    const graph = yield deltaBundler.buildGraph(
      [defaults.moduleSystem].concat(_toConsumableArray(polyfillModuleNames)),
      {
        resolve: yield transformHelpers.getResolveDependencyFn(
          bundler,
          options.platform
        ),
        transform: yield transformHelpers.getTransformFn(
          [defaults.moduleSystem].concat(
            _toConsumableArray(polyfillModuleNames)
          ),
          bundler,
          deltaBundler,
          config,
          transformOptions
        ),
        onProgress: null
      }
github facebook / metro / packages / metro / src / lib / getPrependedScripts.js View on Github external
): Promise<$ReadOnlyArray>> {
  // Get all the polyfills from the relevant option params (the
  // `getPolyfills()` method and the `polyfillModuleNames` variable).
  const polyfillModuleNames = config.serializer
    .getPolyfills({
      platform: options.platform,
    })
    .concat(config.serializer.polyfillModuleNames);

  const transformOptions: TransformInputOptions = {
    ...options,
    type: 'script',
  };

  const graph = await deltaBundler.buildGraph(
    [defaults.moduleSystem, ...polyfillModuleNames],
    {
      resolve: await transformHelpers.getResolveDependencyFn(
        bundler,
        options.platform,
      ),
      transform: await transformHelpers.getTransformFn(
        [defaults.moduleSystem, ...polyfillModuleNames],
        bundler,
        deltaBundler,
        config,
        transformOptions,
      ),
      onProgress: null,
      experimentalImportBundleSupport:
        config.transformer.experimentalImportBundleSupport,
      shallow: false,
github Marwan01 / food-converter / node_modules / metro / src / ModuleGraph / build.js View on Github external
const _ref2 = yield Promise.all([
        _asyncToGenerator(function*() {
          const result = yield graphFn(entryPointPaths);
          const modules = result.modules,
            entryModules = result.entryModules;
          const prModules = postProcessModules(
            modules,
            _toConsumableArray(entryPointPaths)
          );
          return {
            modules: prModules,
            entryModules
          };
        })(),
        graphOnlyModules([translateDefaultsPath(defaults.moduleSystem)]),
        graphOnlyModules(
          getPolyfills({
            platform
          }).map(translateDefaultsPath)
        )
      ]),
      _ref3 = _slicedToArray(_ref2, 3),
      graph = _ref3[0],
      moduleSystem = _ref3[1],
      polyfills = _ref3[2];

    const entryModules = graph.entryModules;
    const preludeScript = virtualModule(
      getPreludeCode({
        extraVars: {
          __FRAMEWORK__: options.framework
github facebook / metro / packages / metro / src / ModuleGraph / build.js View on Github external
optimize,
    platform,
    postProcessModules,
    translateDefaultsPath,
  } = options;

  const graphOnlyModules = async m => (await graphFn(m)).modules;

  const [graph, moduleSystem, polyfills] = await Promise.all([
    (async () => {
      const result = await graphFn(entryPointPaths);
      const {modules, entryModules} = result;
      const prModules = postProcessModules(modules, [...entryPointPaths]);
      return {modules: prModules, entryModules};
    })(),
    graphOnlyModules([translateDefaultsPath(defaults.moduleSystem)]),
    graphOnlyModules(getPolyfills({platform}).map(translateDefaultsPath)),
  ]);

  const {entryModules} = graph;
  const preludeScript = virtualModule(
    getPreludeCode({
      extraVars: {
        __FRAMEWORK__: options.framework,
      },
      isDev: !optimize,
    }),
    '//prelude.js',
  );
  const prependedScripts = [preludeScript, ...moduleSystem, ...polyfills];
  return {
    entryModules,