Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@parcel/core

Package Overview
Dependencies
Maintainers
1
Versions
888
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parcel/core - npm Package Compare versions

Comparing version 2.0.0-nightly.208 to 2.0.0-nightly.212

2

lib/AssetGraphBuilder.js

@@ -185,3 +185,3 @@ "use strict";

this.configRef = configRef;
this.config = new _ParcelConfig.default(config, this.options.packageManager);
this.config = new _ParcelConfig.default(config, this.options.packageManager, this.options.autoinstall);
let {

@@ -188,0 +188,0 @@ requestTracker: tracker,

@@ -87,3 +87,5 @@ "use strict";

let pluginName = (0, _nullthrows.default)(asset.value.plugin);
let plugin = await (0, _loadParcelPlugin.default)(asset.options.packageManager, pluginName, (0, _nullthrows.default)(asset.value.configPath));
let {
plugin
} = await (0, _loadParcelPlugin.default)(asset.options.packageManager, pluginName, (0, _nullthrows.default)(asset.value.configPath), asset.options.autoinstall);

@@ -90,0 +92,0 @@ if (!plugin.generate) {

@@ -97,3 +97,5 @@ "use strict";

let mutableBundleGraph = new _MutableBundleGraph.default(internalBundleGraph, this.options);
let bundler = await this.config.getBundler();
let {
plugin: bundler
} = await this.config.getBundler();

@@ -153,11 +155,9 @@ try {

async getCacheKey(assetGraph) {
let bundler = this.config.getBundlerName();
let name = this.config.getBundlerName();
let {
pkg
} = await this.options.packageManager.resolve(`${bundler}/package.json`, `${this.config.filePath}/index` // TODO: is this right?
);
let version = (0, _nullthrows.default)(pkg).version;
version
} = await this.config.getBundler();
return (0, _utils.md5FromObject)({
parcelVersion: _constants.PARCEL_VERSION,
bundler,
name,
version,

@@ -164,0 +164,0 @@ hash: assetGraph.getHash()

@@ -117,3 +117,5 @@ "use strict";

(0, _assert.default)(typeof parcelConfigPath === 'string');
let pluginInstance = await this.parcelConfig.loadPlugin({
let {
plugin: pluginInstance
} = await this.parcelConfig.loadPlugin({
packageName: (0, _nullthrows.default)(plugin),

@@ -120,0 +122,0 @@ resolveFrom: parcelConfigPath

@@ -166,3 +166,3 @@ "use strict";

}, configFile));
let config = new _ParcelConfig.default(resolvedFile, options.packageManager);
let config = new _ParcelConfig.default(resolvedFile, options.packageManager, options.autoinstall);
let extendedFiles = [];

@@ -230,3 +230,3 @@

reporters: mergePipelines(base.reporters, ext.reporters)
}, base.packageManager);
}, base.packageManager, base.autoinstall);
}

@@ -233,0 +233,0 @@

@@ -14,2 +14,4 @@ "use strict";

var _nullthrows = _interopRequireDefault(require("nullthrows"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -19,7 +21,9 @@

async function loadPlugin(packageManager, pluginName, resolveFrom) {
async function loadPlugin(packageManager, pluginName, resolveFrom, autoinstall) {
let {
resolved,
pkg
} = await packageManager.resolve(pluginName, `${resolveFrom}/index`); // Validate the engines.parcel field in the plugin's package.json
} = await packageManager.resolve(pluginName, `${resolveFrom}/index`, {
autoinstall
}); // Validate the engines.parcel field in the plugin's package.json

@@ -39,3 +43,5 @@ let parcelVersionRange = pkg && pkg.engines && pkg.engines.parcel;

let plugin = await packageManager.require(resolved, `${resolveFrom}/index`);
let plugin = await packageManager.require(resolved, `${resolveFrom}/index`, {
autoinstall
});
plugin = plugin.default ? plugin.default : plugin;

@@ -53,3 +59,6 @@

return plugin;
return {
plugin,
version: (0, _nullthrows.default)(pkg).version
};
}

@@ -309,14 +309,12 @@ "use strict";

getCacheKey(bundle, bundleGraph) {
async getCacheKey(bundle, bundleGraph) {
let filePath = (0, _nullthrows.default)(bundle.filePath); // TODO: include packagers and optimizers used in inline bundles as well
let packager = this.config.getPackagerName(filePath);
let optimizers = this.config.getOptimizerNames(filePath);
let deps = Promise.all([packager, ...optimizers].map(async pkg => {
let {
pkg: resolvedPkg
} = await this.options.packageManager.resolve(`${pkg}/package.json`, `${this.config.filePath}/index`);
let version = (0, _nullthrows.default)(resolvedPkg).version;
return [pkg, version];
})); // TODO: add third party configs to the cache key
let {
version: packager
} = await this.config.getPackager(filePath);
let optimizers = (await this.config.getOptimizers(filePath)).map(({
name,
version
}) => [name, version]); // TODO: add third party configs to the cache key

@@ -328,3 +326,4 @@ let {

parcelVersion: _constants.PARCEL_VERSION,
deps,
packager,
optimizers,
opts: {

@@ -331,0 +330,0 @@ sourceMaps

@@ -19,3 +19,3 @@ "use strict";

class ParcelConfig {
constructor(config, packageManager) {
constructor(config, packageManager, autoinstall) {
_defineProperty(this, "packageManager", void 0);

@@ -45,2 +45,4 @@

_defineProperty(this, "autoinstall", void 0);
this.packageManager = packageManager;

@@ -58,6 +60,7 @@ this.filePath = config.filePath;

this.pluginCache = new Map();
this.autoinstall = autoinstall;
}
static deserialize(serialized) {
return new ParcelConfig(serialized.config, serialized.packageManager);
return new ParcelConfig(serialized.config, serialized.packageManager, serialized.autoinstall);
}

@@ -84,3 +87,4 @@

packageManager: this.packageManager,
config: this.getConfig()
config: this.getConfig(),
autoinstall: this.autoinstall
};

@@ -96,3 +100,3 @@ }

plugin = (0, _loadParcelPlugin.default)(this.packageManager, node.packageName, node.resolveFrom);
plugin = (0, _loadParcelPlugin.default)(this.packageManager, node.packageName, node.resolveFrom, this.autoinstall);
this.pluginCache.set(node.packageName, plugin);

@@ -104,5 +108,10 @@ return plugin;

return Promise.all(plugins.map(async p => {
let {
plugin,
version
} = await this.loadPlugin(p);
return {
name: p.packageName,
plugin: await this.loadPlugin(p),
plugin,
version,
resolveFrom: p.resolveFrom

@@ -221,5 +230,10 @@ };

let {
plugin,
version
} = await this.loadPlugin(packager);
return {
name: packager.packageName,
plugin: await this.loadPlugin(packager)
version,
plugin
};

@@ -226,0 +240,0 @@ }

@@ -125,3 +125,5 @@ "use strict";

let plugin = await this.parcelConfig.loadPlugin({
let {
plugin
} = await this.parcelConfig.loadPlugin({
packageName: request.plugin,

@@ -128,0 +130,0 @@ resolveFrom

@@ -62,6 +62,14 @@ "use strict";

throw new Error('Expected package version to be a string');
}
} // $FlowFixMe
for (let ctor of [_AssetGraph.default, _Config.default, _BundleGraph.default, _Graph.default, _ParcelConfig.default, _RequestTracker.RequestGraph]) {
(0, _serializer.registerSerializableClass)(packageVersion + ':' + ctor.name, ctor);
for (let [name, ctor] of Object.entries({
AssetGraph: _AssetGraph.default,
Config: _Config.default,
BundleGraph: _BundleGraph.default,
Graph: _Graph.default,
ParcelConfig: _ParcelConfig.default,
RequestGraph: _RequestTracker.RequestGraph
})) {
(0, _serializer.registerSerializableClass)(packageVersion + ':' + name, ctor);
}

@@ -68,0 +76,0 @@

@@ -58,3 +58,3 @@ "use strict";

);
let config = new _ParcelConfig.default(processedConfig, options.packageManager);
let config = new _ParcelConfig.default(processedConfig, options.packageManager, options.autoinstall);
return new _Transformation.default(_objectSpread({

@@ -79,3 +79,3 @@ workerApi,

);
let config = new _ParcelConfig.default(processedConfig, options.packageManager);
let config = new _ParcelConfig.default(processedConfig, options.packageManager, options.autoinstall);
return new _Validation.default(_objectSpread({

@@ -102,3 +102,3 @@ workerApi,

);
let config = new _ParcelConfig.default(processedConfig, options.packageManager);
let config = new _ParcelConfig.default(processedConfig, options.packageManager, options.autoinstall);
return new _PackagerRunner.default({

@@ -105,0 +105,0 @@ config,

{
"name": "@parcel/core",
"version": "2.0.0-nightly.208+10e18b0a",
"version": "2.0.0-nightly.212+52fd6741",
"license": "MIT",

@@ -19,13 +19,13 @@ "publishConfig": {

"dependencies": {
"@parcel/cache": "2.0.0-nightly.210+10e18b0a",
"@parcel/diagnostic": "2.0.0-nightly.210+10e18b0a",
"@parcel/events": "2.0.0-nightly.210+10e18b0a",
"@parcel/fs": "2.0.0-nightly.210+10e18b0a",
"@parcel/logger": "2.0.0-nightly.210+10e18b0a",
"@parcel/package-manager": "2.0.0-nightly.210+10e18b0a",
"@parcel/plugin": "2.0.0-nightly.210+10e18b0a",
"@parcel/source-map": "^2.0.0-alpha.4.6",
"@parcel/types": "2.0.0-nightly.210+10e18b0a",
"@parcel/utils": "2.0.0-nightly.210+10e18b0a",
"@parcel/workers": "2.0.0-nightly.210+10e18b0a",
"@parcel/cache": "2.0.0-nightly.214+52fd6741",
"@parcel/diagnostic": "2.0.0-nightly.214+52fd6741",
"@parcel/events": "2.0.0-nightly.214+52fd6741",
"@parcel/fs": "2.0.0-nightly.214+52fd6741",
"@parcel/logger": "2.0.0-nightly.214+52fd6741",
"@parcel/package-manager": "2.0.0-nightly.214+52fd6741",
"@parcel/plugin": "2.0.0-nightly.214+52fd6741",
"@parcel/source-map": "^2.0.0-alpha.4.9",
"@parcel/types": "2.0.0-nightly.214+52fd6741",
"@parcel/utils": "2.0.0-nightly.214+52fd6741",
"@parcel/workers": "2.0.0-nightly.214+52fd6741",
"abortcontroller-polyfill": "^1.1.9",

@@ -46,3 +46,3 @@ "browserslist": "^4.6.6",

},
"gitHead": "10e18b0a440b1678ef0fdcd7d104a1394a5ed6f6"
"gitHead": "52fd6741a0ea1f2e043c628cf6b7be0715b1c837"
}

@@ -175,3 +175,7 @@ // @flow strict-local

this.configRef = configRef;
this.config = new ParcelConfig(config, this.options.packageManager);
this.config = new ParcelConfig(
config,
this.options.packageManager,
this.options.autoinstall,
);
let {

@@ -178,0 +182,0 @@ requestTracker: tracker,

@@ -114,6 +114,7 @@ // @flow strict-local

let pluginName = nullthrows(asset.value.plugin);
let plugin: Transformer = await loadPlugin(
let {plugin} = await loadPlugin<Transformer>(
asset.options.packageManager,
pluginName,
nullthrows(asset.value.configPath),
asset.options.autoinstall,
);

@@ -120,0 +121,0 @@ if (!plugin.generate) {

@@ -80,3 +80,3 @@ // @flow strict-local

let bundler = await this.config.getBundler();
let {plugin: bundler} = await this.config.getBundler();

@@ -132,12 +132,8 @@ try {

async getCacheKey(assetGraph: AssetGraph) {
let bundler = this.config.getBundlerName();
let {pkg} = await this.options.packageManager.resolve(
`${bundler}/package.json`,
`${this.config.filePath}/index`, // TODO: is this right?
);
let name = this.config.getBundlerName();
let {version} = await this.config.getBundler();
let version = nullthrows(pkg).version;
return md5FromObject({
parcelVersion: PARCEL_VERSION,
bundler,
name,
version,

@@ -165,3 +161,8 @@ hash: assetGraph.getHash(),

async nameBundle(
namers: Array<{|name: string, plugin: Namer, resolveFrom: FilePath|}>,
namers: Array<{|
name: string,
version: string,
plugin: Namer,
resolveFrom: FilePath,
|}>,
internalBundle: InternalBundle,

@@ -168,0 +169,0 @@ internalBundleGraph: InternalBundleGraph,

@@ -98,3 +98,3 @@ // @flow

invariant(typeof parcelConfigPath === 'string');
let pluginInstance = await this.parcelConfig.loadPlugin({
let {plugin: pluginInstance} = await this.parcelConfig.loadPlugin({
packageName: nullthrows(plugin),

@@ -101,0 +101,0 @@ resolveFrom: parcelConfigPath,

@@ -183,3 +183,7 @@ // @flow

});
let config = new ParcelConfig(resolvedFile, options.packageManager);
let config = new ParcelConfig(
resolvedFile,
options.packageManager,
options.autoinstall,
);

@@ -271,2 +275,3 @@ let extendedFiles: Array<FilePath> = [];

base.packageManager,
base.autoinstall,
);

@@ -273,0 +278,0 @@ }

// @flow
import type {FilePath, PackageName, Semver} from '@parcel/types';
import type {PackageManager} from '@parcel/package-manager';
import semver from 'semver';
import logger from '@parcel/logger';
import {CONFIG} from '@parcel/plugin';
import type {FilePath, PackageName} from '@parcel/types';
import type {PackageManager} from '@parcel/package-manager';
import nullthrows from 'nullthrows';
const PARCEL_VERSION = require('../package.json').version;
export default async function loadPlugin(
export default async function loadPlugin<T>(
packageManager: PackageManager,
pluginName: PackageName,
resolveFrom: FilePath,
) {
autoinstall: boolean,
): Promise<{|plugin: T, version: Semver|}> {
let {resolved, pkg} = await packageManager.resolve(
pluginName,
`${resolveFrom}/index`,
{autoinstall},
);

@@ -39,3 +42,5 @@

let plugin = await packageManager.require(resolved, `${resolveFrom}/index`);
let plugin = await packageManager.require(resolved, `${resolveFrom}/index`, {
autoinstall,
});
plugin = plugin.default ? plugin.default : plugin;

@@ -51,3 +56,3 @@ if (!plugin) {

}
return plugin;
return {plugin, version: nullthrows(pkg).version};
}

@@ -366,22 +366,13 @@ // @flow strict-local

getCacheKey(
async getCacheKey(
bundle: InternalBundle,
bundleGraph: InternalBundleGraph,
): string {
): Promise<string> {
let filePath = nullthrows(bundle.filePath);
// TODO: include packagers and optimizers used in inline bundles as well
let packager = this.config.getPackagerName(filePath);
let optimizers = this.config.getOptimizerNames(filePath);
let deps = Promise.all(
[packager, ...optimizers].map(async pkg => {
let {pkg: resolvedPkg} = await this.options.packageManager.resolve(
`${pkg}/package.json`,
`${this.config.filePath}/index`,
);
let {version: packager} = await this.config.getPackager(filePath);
let optimizers = (
await this.config.getOptimizers(filePath)
).map(({name, version}) => [name, version]);
let version = nullthrows(resolvedPkg).version;
return [pkg, version];
}),
);
// TODO: add third party configs to the cache key

@@ -391,3 +382,4 @@ let {sourceMaps} = this.options;

parcelVersion: PARCEL_VERSION,
deps,
packager,
optimizers,
opts: {sourceMaps},

@@ -394,0 +386,0 @@ hash: bundleGraph.getHash(bundle),

@@ -12,5 +12,6 @@ // @flow

PackageName,
Optimizer,
Packager,
Optimizer,
Reporter,
Semver,
Validator,

@@ -34,2 +35,3 @@ } from '@parcel/types';

packageManager: PackageManager,
autoinstall: boolean,
|};

@@ -50,4 +52,9 @@

pluginCache: Map<PackageName, any>;
autoinstall: boolean;
constructor(config: ProcessedParcelConfig, packageManager: PackageManager) {
constructor(
config: ProcessedParcelConfig,
packageManager: PackageManager,
autoinstall: boolean,
) {
this.packageManager = packageManager;

@@ -65,6 +72,11 @@ this.filePath = config.filePath;

this.pluginCache = new Map();
this.autoinstall = autoinstall;
}
static deserialize(serialized: SerializedParcelConfig) {
return new ParcelConfig(serialized.config, serialized.packageManager);
return new ParcelConfig(
serialized.config,
serialized.packageManager,
serialized.autoinstall,
);
}

@@ -92,6 +104,9 @@

config: this.getConfig(),
autoinstall: this.autoinstall,
};
}
loadPlugin(node: ParcelPluginNode) {
loadPlugin<T>(
node: ParcelPluginNode,
): Promise<{|plugin: T, version: Semver|}> {
let plugin = this.pluginCache.get(node.packageName);

@@ -102,6 +117,7 @@ if (plugin) {

plugin = loadPlugin(
plugin = loadPlugin<T>(
this.packageManager,
node.packageName,
node.resolveFrom,
this.autoinstall,
);

@@ -117,2 +133,3 @@ this.pluginCache.set(node.packageName, plugin);

name: string,
version: Semver,
plugin: T,

@@ -124,5 +141,7 @@ resolveFrom: FilePath,

plugins.map(async p => {
let {plugin, version} = await this.loadPlugin<T>(p);
return {
name: p.packageName,
plugin: await this.loadPlugin(p),
plugin,
version,
resolveFrom: p.resolveFrom,

@@ -210,3 +229,3 @@ };

getBundler(): Promise<Bundler> {
getBundler(): Promise<{|version: Semver, plugin: Bundler|}> {
if (!this.bundler) {

@@ -216,3 +235,3 @@ throw new Error('No bundler specified in .parcelrc config');

return this.loadPlugin(this.bundler);
return this.loadPlugin<Bundler>(this.bundler);
}

@@ -233,2 +252,3 @@

name: string,
version: Semver,
plugin: Runtime,

@@ -262,2 +282,3 @@ resolveFrom: FilePath,

name: string,
version: Semver,
plugin: Packager,

@@ -267,5 +288,7 @@ |}> {

let {plugin, version} = await this.loadPlugin<Packager>(packager);
return {
name: packager.packageName,
plugin: await this.loadPlugin(packager),
version,
plugin,
};

@@ -291,2 +314,3 @@ }

name: string,
version: Semver,
plugin: Optimizer,

@@ -293,0 +317,0 @@ resolveFrom: FilePath,

@@ -128,3 +128,3 @@ // @flow strict-local

let plugin = await this.parcelConfig.loadPlugin({
let {plugin} = await this.parcelConfig.loadPlugin({
packageName: request.plugin,

@@ -131,0 +131,0 @@ resolveFrom,

@@ -41,3 +41,4 @@ // @flow strict-local

for (let ctor of [
// $FlowFixMe
for (let [name, ctor] of (Object.entries({
AssetGraph,

@@ -49,4 +50,4 @@ Config,

RequestGraph,
]) {
registerSerializableClass(packageVersion + ':' + ctor.name, ctor);
}): Array<[string, Class<*>]>)) {
registerSerializableClass(packageVersion + ':' + name, ctor);
}

@@ -53,0 +54,0 @@

@@ -46,3 +46,7 @@ // @flow strict-local

): any): ProcessedParcelConfig);
let config = new ParcelConfig(processedConfig, options.packageManager);
let config = new ParcelConfig(
processedConfig,
options.packageManager,
options.autoinstall,
);

@@ -68,3 +72,7 @@ return new Transformation({

): any): ProcessedParcelConfig);
let config = new ParcelConfig(processedConfig, options.packageManager);
let config = new ParcelConfig(
processedConfig,
options.packageManager,
options.autoinstall,
);

@@ -110,3 +118,7 @@ return new Validation({

): any): ProcessedParcelConfig);
let config = new ParcelConfig(processedConfig, options.packageManager);
let config = new ParcelConfig(
processedConfig,
options.packageManager,
options.autoinstall,
);

@@ -113,0 +125,0 @@ return new PackagerRunner({

@@ -475,2 +475,3 @@ // @flow

DEFAULT_OPTIONS.packageManager,
false,
);

@@ -540,2 +541,3 @@

DEFAULT_OPTIONS.packageManager,
false,
);

@@ -654,6 +656,2 @@

},
// e => {
// console.log(e);
// return true;
// },
);

@@ -660,0 +658,0 @@ });

@@ -30,2 +30,3 @@ // @flow

packageManager,
false,
);

@@ -69,2 +70,3 @@

packageManager,
false,
);

@@ -133,6 +135,7 @@

packageManager,
false,
);
sinon.stub(logger, 'warn');
let plugin = await config.loadPlugin({
let {plugin} = await config.loadPlugin({
packageName: 'parcel-transformer-no-engines',

@@ -173,2 +176,3 @@ resolveFrom: configFilePath,

packageManager,
false,
);

@@ -175,0 +179,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc