Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish bundle-stats-cli and parcel-query #9431

Merged
merged 14 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const paths = {
packageJson: [
'packages/core/parcel/package.json',
'packages/utils/create-react-app/package.json',
'packages/dev/query/package.json',
'packages/dev/bundle-stats-cli/package.json',
mischnic marked this conversation as resolved.
Show resolved Hide resolved
],
packages: 'packages/',
};
Expand Down
12 changes: 0 additions & 12 deletions packages/dev/bundle-stats-cli/bin.js

This file was deleted.

19 changes: 15 additions & 4 deletions packages/dev/bundle-stats-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
{
"name": "@parcel/bundle-stats-cli",
"name": "@parcel/bundle-stats",
"version": "2.10.3",
"private": true,
"license": "MIT",
"publishConfig": {
"access": "public"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/parcel.git"
},
"main": "lib/cli.js",
"source": "src/cli.js",
"bin": {
"parcel-bundle-stats": "bin.js"
"parcel-bundle-stats": "src/bin.js"
},
"engines": {
"node": ">= 12.0.0",
Expand All @@ -16,7 +27,7 @@
"@parcel/reporter-bundle-stats": "2.10.3",
"@parcel/utils": "2.10.3",
"commander": "^7.0.0",
"parcel-query": "2.10.3"
"@parcel/query": "2.10.3"
},
"devDependencies": {
"@parcel/babel-register": "2.10.3",
Expand Down
14 changes: 14 additions & 0 deletions packages/dev/bundle-stats-cli/src/bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /usr/bin/env node

'use strict';

if (
process.env.PARCEL_BUILD_ENV !== 'production' ||
process.env.PARCEL_SELF_BUILD
) {
require('@parcel/babel-register');
}

const cli = require('./cli');

cli.command.parse();
12 changes: 6 additions & 6 deletions packages/dev/bundle-stats-cli/src/cli.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/* eslint-disable no-console, monorepo/no-internal-import */
// @flow strict-local

import type {PackagedBundle} from '@parcel/types';
import type {ParcelOptions} from '@parcel/core/src/types';
import type {commander$Command} from 'commander';

// $FlowFixMe[untyped-import]
import {version} from '../package.json';

import commander from 'commander';
import fs from 'fs';
import path from 'path';

import {DefaultMap} from '@parcel/utils';

import {loadGraphs} from 'parcel-query/src/index.js';
import {getBundleStats} from '@parcel/reporter-bundle-stats/src/BundleStatsReporter';
import {PackagedBundle as PackagedBundleClass} from '@parcel/core/src/public/Bundle';
import type {commander$Command} from 'commander';
const {
loadGraphs,
getBundleStats,
PackagedBundleClass,
} = require('./deep-imports.js');

async function run({cacheDir, outDir}) {
// 1. load bundle graph and info via parcel~query
Expand Down
30 changes: 30 additions & 0 deletions packages/dev/bundle-stats-cli/src/deep-imports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// @flow
/* eslint-disable monorepo/no-internal-import */
import typeof {loadGraphs} from '@parcel/query/src/index.js';
import typeof {getBundleStats} from '@parcel/reporter-bundle-stats/src/BundleStatsReporter';
import typeof {PackagedBundle as PackagedBundleClass} from '@parcel/core/src/public/Bundle';

module.exports = ((process.env.PARCEL_BUILD_ENV === 'production'
? {
// Split up require specifier to outsmart packages/dev/babel-register/babel-plugin-module-translate.js
// $FlowFixMe(unsupported-syntax)
loadGraphs: require('@parcel/query' + '/lib/index.js').loadGraphs,
// $FlowFixMe(unsupported-syntax)
getBundleStats: require('@parcel/reporter-bundle-stats' +
'/lib/BundleStatsReporter.js').getBundleStats,
// $FlowFixMe(unsupported-syntax)
PackagedBundleClass: require('@parcel/core' + '/lib/public/Bundle.js')
.PackagedBundle,
}
: {
loadGraphs: require('@parcel/query/src/index.js').loadGraphs,
getBundleStats:
require('@parcel/reporter-bundle-stats/src/BundleStatsReporter.js')
.getBundleStats,
PackagedBundleClass: require('@parcel/core/src/public/Bundle.js')
.PackagedBundle,
}): {|
loadGraphs: loadGraphs,
getBundleStats: getBundleStats,
PackagedBundleClass: PackagedBundleClass,
|});
19 changes: 16 additions & 3 deletions packages/dev/query/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"name": "parcel-query",
"name": "@parcel/query",
"version": "2.10.3",
"private": true,
"bin": "src/bin.js",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/parcel.git"
},
"bin": {
"parcel-query": "src/bin.js"
},
"main": "src/index.js",
"dependencies": {
"@parcel/cache": "2.10.3",
Expand Down
13 changes: 7 additions & 6 deletions packages/dev/query/src/cli.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @flow strict-local
/* eslint-disable no-console, monorepo/no-internal-import */
import type {ContentGraph, ContentKey, NodeId} from '@parcel/graph';
import type {BundleGraphEdgeType} from '@parcel/core/src/BundleGraph';
import type {AssetGraphNode, BundleGraphNode} from '@parcel/core/src/types';
import type {BundleGraphEdgeType} from '@parcel/core/src/BundleGraph.js';

import path from 'path';
import fs from 'fs';
Expand All @@ -11,16 +11,17 @@ import os from 'os';
import nullthrows from 'nullthrows';
import invariant from 'assert';
import {serialize} from 'v8';

// $FlowFixMe
import {table} from 'table';

import {fromProjectPathRelative} from '@parcel/core/src/projectPath';
import {bundleGraphEdgeTypes} from '@parcel/core/src/BundleGraph.js';
import {Priority} from '@parcel/core/src/types';

import {loadGraphs} from './index.js';

const {
BundleGraph: {bundleGraphEdgeTypes: bundleGraphEdgeTypes},
Priority,
fromProjectPathRelative,
} = require('./deep-imports.js');

export async function run(input: string[]) {
let args = input;
let cacheDir = path.join(process.cwd(), '.parcel-cache');
Expand Down
62 changes: 44 additions & 18 deletions packages/dev/query/src/deep-imports.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,59 @@
// @flow
/* eslint-disable monorepo/no-internal-import */
import typeof AssetGraph from '@parcel/core/src/AssetGraph.js';
import typeof BundleGraph from '@parcel/core/src/BundleGraph.js';
import typeof BundleGraph, {
bundleGraphEdgeTypes,
} from '@parcel/core/src/BundleGraph.js';
import typeof RequestTracker, {
RequestGraph,
} from '@parcel/core/src/RequestTracker.js';
import {typeof requestGraphEdgeTypes} from '@parcel/core/src/RequestTracker.js';
import typeof {requestGraphEdgeTypes} from '@parcel/core/src/RequestTracker.js';
import typeof {LMDBCache} from '@parcel/cache/src/LMDBCache.js';
import typeof {Priority} from '@parcel/core/src/types.js';
import typeof {fromProjectPathRelative} from '@parcel/core/src/projectPath.js';

module.exports = ((process.env.PARCEL_BUILD_ENV === 'production'
? {
// Split up require specifier to outsmart packages/dev/babel-register/babel-plugin-module-translate.js
// $FlowFixMe(unsupported-syntax)
AssetGraph: require('@parcel/core' + '/lib/AssetGraph.js').default,
// $FlowFixMe(unsupported-syntax)
BundleGraph: require('@parcel/core' + '/lib/BundleGraph.js').default,
// $FlowFixMe(unsupported-syntax)
RequestTracker: require('@parcel/core' + '/lib/RequestTracker.js'),
}
: {
AssetGraph: require('@parcel/core/src/AssetGraph.js').default,
BundleGraph: require('@parcel/core/src/BundleGraph.js').default,
RequestTracker: require('@parcel/core/src/RequestTracker.js'),
}): {|
const v =
process.env.PARCEL_BUILD_ENV === 'production'
? {
// Split up require specifier to outsmart packages/dev/babel-register/babel-plugin-module-translate.js
// $FlowFixMe(unsupported-syntax)
AssetGraph: require('@parcel/core' + '/lib/AssetGraph.js').default,
// $FlowFixMe(unsupported-syntax)
BundleGraph: require('@parcel/core' + '/lib/BundleGraph.js'),
// $FlowFixMe(unsupported-syntax)
RequestTracker: require('@parcel/core' + '/lib/RequestTracker.js'),
// $FlowFixMe(unsupported-syntax)
LMDBCache: require('@parcel/cache' + '/lib/LMDBCache.js').LMDBCache,
// $FlowFixMe(unsupported-syntax)
Priority: require('@parcel/core' + '/lib/types.js').Priority,
// $FlowFixMe(unsupported-syntax)
fromProjectPathRelative: require('@parcel/core' + '/lib/projectPath.js')
.fromProjectPathRelative,
}
: {
AssetGraph: require('@parcel/core/src/AssetGraph.js').default,
BundleGraph: require('@parcel/core/src/BundleGraph.js'),
RequestTracker: require('@parcel/core/src/RequestTracker.js'),
LMDBCache: require('@parcel/cache/src/LMDBCache.js').LMDBCache,
Priority: require('@parcel/core/src/types.js').Priority,
fromProjectPathRelative: require('@parcel/core/src/projectPath.js')
.fromProjectPathRelative,
};

module.exports = (v: {|
AssetGraph: AssetGraph,
BundleGraph: BundleGraph,
BundleGraph: {
default: BundleGraph,
bundleGraphEdgeTypes: bundleGraphEdgeTypes,
...
},
RequestTracker: {
default: RequestTracker,
RequestGraph: RequestGraph,
requestGraphEdgeTypes: requestGraphEdgeTypes,
...
},
LMDBCache: LMDBCache,
Priority: Priority,
fromProjectPathRelative: fromProjectPathRelative,
|});
4 changes: 2 additions & 2 deletions packages/dev/query/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import path from 'path';
import v8 from 'v8';
import nullthrows from 'nullthrows';
import invariant from 'assert';
import {LMDBCache} from '@parcel/cache/src/LMDBCache';

const {
AssetGraph,
BundleGraph,
BundleGraph: {default: BundleGraph},
RequestTracker: {
default: RequestTracker,
RequestGraph,
requestGraphEdgeTypes,
},
LMDBCache,
} = require('./deep-imports.js');

export async function loadGraphs(cacheDir: string): Promise<{|
Expand Down