How to use the @codesandbox/common/lib/utils/path.absolute function in @codesandbox/common

To help you get started, we’ve selected a few @codesandbox/common 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 codesandbox / codesandbox-client / packages / app / src / sandbox / compile.ts View on Github external
const possibleEntries = templateDefinition.getEntries(configurations);

    const foundMain = isModuleView
      ? entry
      : possibleEntries.find(p => Boolean(modules[p]));

    if (!foundMain) {
      throw new Error(
        `Could not find entry file: ${
          possibleEntries[0]
        }. You can specify one in package.json by defining a \`main\` property.`
      );
    }

    const main = absolute(foundMain);
    managerModuleToTranspile = modules[main];

    // TODO: make this a separate lifecycle
    // await manager.preset.setup(manager);

    dispatch({ type: 'status', status: 'transpiling' });
    manager.setStage('transpilation');

    await manager.verifyTreeTranspiled();
    await manager.transpileModules(managerModuleToTranspile);

    debug(`Transpilation time ${Date.now() - t}ms`);

    dispatch({ type: 'status', status: 'evaluating' });
    manager.setStage('evaluation');
github codesandbox / codesandbox-client / packages / app / src / sandbox / compile.ts View on Github external
const possibleEntries = templateDefinition.getEntries(configurations);

    const foundMain = isModuleView
      ? entry
      : possibleEntries.find(p => !!modules[p]);

    if (!foundMain) {
      throw new Error(
        `Could not find entry file: ${
          possibleEntries[0]
        }. You can specify one in package.json by defining a \`main\` property.`
      );
    }

    const main = absolute(foundMain);
    managerModuleToTranspile = modules[main];

    // TODO: make this a separate lifecycle
    // await manager.preset.setup(manager);

    dispatch({ type: 'status', status: 'transpiling' });
    manager.setStage('transpilation');

    await manager.verifyTreeTranspiled();
    await manager.transpileModules(managerModuleToTranspile);

    debug(`Transpilation time ${Date.now() - t}ms`);

    dispatch({ type: 'status', status: 'evaluating' });
    manager.setStage('evaluation');
github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / transpilers / sass / worker / sass-worker.js View on Github external
async (err, resolvedPath) => {
        if (err) {
          if (/^\w/.test(p)) {
            r(resolveSass(fs, '.' + absolute(p), path));
          }

          reject(err);
        } else {
          const foundPath = await getExistingPath(fs, resolvedPath);

          r(foundPath);
        }
      }
    );
github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / transpilers / sass / worker / sass-worker.js View on Github external
async (err, resolvedPath) => {
        if (err) {
          if (/^\w/.test(p)) {
            r(resolveSass(fs, '.' + absolute(p), path));
          }

          reject(err);
        } else {
          const foundPath = await getExistingPath(fs, resolvedPath);

          r(foundPath);
        }
      }
    );
github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / presets / angular-cli / index.js View on Github external
async function addAngularCLIPolyfills(manager) {
  const { parsed } = manager.configurations['angular-cli'];
  if (parsed.apps && parsed.apps[0]) {
    const app = parsed.apps[0];

    if (app.root && app.polyfills) {
      const polyfillLocation = absolute(join(app.root, app.polyfills));
      const polyfills = manager.resolveModule(polyfillLocation, '/');

      await manager.transpileModules(polyfills);
      manager.evaluateModule(polyfills);
    }
  }
}
github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / presets / angular-cli / index.js View on Github external
async function addAngularJSONPolyfills(manager) {
  const { parsed } = manager.configurations['angular-config'];

  const { defaultProject } = parsed;
  const project = parsed.projects[defaultProject];
  const { build } = project.architect;

  if (build.options) {
    if (project.root && build.options.polyfill) {
      const polyfillLocation = absolute(
        join(project.root, build.options.polyfill)
      );
      const polyfills = manager.resolveModule(polyfillLocation, '/');

      await manager.transpileModules(polyfills);
      manager.evaluateModule(polyfills);
    }
  }
}