Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
translators.set('json', async function jsonStrategy(url) {
debug(`Translating JSONModule ${url}`);
debug(`Loading JSONModule ${url}`);
const pathname = url.startsWith('file:') ? fileURLToPath(url) : null;
let modulePath;
let module;
if (pathname) {
modulePath = isWindows ?
StringPrototype.replace(pathname, winSepRegEx, '\\') : pathname;
module = CJSModule._cache[modulePath];
if (module && module.loaded) {
const exports = module.exports;
return createDynamicModule([], ['default'], url, (reflect) => {
reflect.exports.default.set(exports);
});
}
}
const content = `${await getSource(url)}`;
if (pathname) {
// A require call could have been called on the same file during loading and
flatMapConcurrent(pickResourceRetriever(pattern).glob(pattern), 10, async function*(
tsconfigUri
): AsyncGenerator {
throwIfCancelled(token)
let json: string | undefined
try {
json = await pickResourceRetriever(tsconfigUri).fetch(tsconfigUri)
const tsconfig = JSON5.parse(json)
if (tsconfig && tsconfig.compilerOptions && tsconfig.compilerOptions.plugins) {
// Remove plugins for security reasons (they get loaded from node_modules)
tsconfig.compilerOptions.plugins = undefined
await writeFile(fileURLToPath(tsconfigUri), JSON.stringify(tsconfig))
}
} catch (err) {
throwIfCancelled(token)
logger.error('Error sanitizing tsconfig.json at', tsconfigUri, json, err)
logErrorEvent(span, err)
}
})
})
assert.throws(() => url.fileURLToPath(withHost), {
code: 'ERR_INVALID_FILE_URL_HOST'
import util from 'util';
import fs from 'fs-extra';
import chalk from 'ansi-colors';
import sass from 'sass';
import Console from '../utils/console.js';
import countTime from '../utils/count-time.js';
import findProjectRoot from '../utils/find-project-root.js';
import lookup from '../utils/recursive-file-lookup.js';
import say from '../utils/say.js';
import { formatTimePassed, formatSize } from '../utils/asset-reporter.js';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const compileScssAsync = util.promisify(sass.render);
export default function(buildConfig={
applicationName: null,
buildCache: {
vendorAppends: '', vendorPrepends: '', applicationAppends: '', applicationPrepends: ''
},
cliArguments: {},
ENV: {},
indexHTMLInjections: {},
projectRoot: null,
}) {
return new Promise(async (resolve, reject) => {
Console.log(chalk.yellow('BUILDING:'), 'documentation.css...');
import buildIndexHTML from './build-index-html.js';
import buildCSS from './build-css.js';
import buildVendor from './build-vendor.js';
import buildApplication from './build-application.js';
import buildDocumentation from './build-documentation.js';
import buildDocumentationCSS from './build-documentation-css.js';
import buildDocumentationHTML from './build-documentation-html.js';
import buildMemServer from './build-memserver.js';
import buildTests from './build-tests.js';
import buildFastbootPackageJSON from './build-fastboot-package-json.js';
import Console from '../utils/console.js';
import findProjectRoot from '../utils/find-project-root.js';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const VENDOR_PATH = `${__dirname}/../../vendor`;
export default function(buildConfig={
applicationName: null,
buildCache: {
vendorAppends: '', vendorPrepends: '', applicationAppends: '', applicationPrepends: ''
},
cliArguments: null,
ENV: null,
indexHTMLInjections: {},
projectRoot: null,
}, lint=true) {
return new Promise(async (resolve) => {
const projectRoot = buildConfig.projectRoot || await findProjectRoot();
const cliArguments = buildConfig.cliArguments || {};
const ENV = buildConfig.ENV || {
import path from 'path';
import fs from 'fs';
import chalk from 'chalk';
import crypto from 'crypto';
import gzipSize from 'gzip-size';
import CliTable from 'cli-table';
import prettyBytes from './prettyBytes.js';
import formatSize from './formatSize.js';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
/*
POST PRODUCTION:
* Build a list of assets by reading webpack manifest
* Detect entry point
* Mark route assets
* For each route asset, store its chunk dependencies
* We must be able to add preload headers for all deps when navigating to a route
* e.g. entry point + route + route deps...
* Process each asset in parallel
* Generate application manifest
* Store assets that need to be uploaded to the CDN
* Store entrypoint
* Store chunk dependencies for each route
* Display report
public async exists(resource: URL): Promise {
return await exists(fileURLToPath(resource))
}
function errPath(url) {
const parsed = new URL(url);
if (parsed.protocol === 'file:') {
return fileURLToPath(parsed);
}
return url;
}
function fileURLToPath(uri) {
assert(typeof uri === 'string');
if (url.fileURLToPath)
return resolve(url.fileURLToPath(uri), '.');
try {
uri = url.parse(uri);
} catch (e) {
const err = new TypeError(`Invalid URL: ${uri}`);
err.code = 'ERR_INVALID_URL';
throw err;
}
if (uri.protocol !== 'file:') {
const err = new TypeError('The URL must be of scheme file');
err.code = 'ERR_INVALID_URL_SCHEME';
throw err;
}
if (uri.port != null) {