Skip to content

Commit c312026

Browse files
committed
Revert "Support inline server functions (#10162)"
This reverts commit 9855f55.
1 parent 5b71920 commit c312026

File tree

23 files changed

+1063
-2892
lines changed

23 files changed

+1063
-2892
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ packages/*/*/test/mochareporters.json
77
packages/*/*/test/fixtures
88
packages/*/*/test/.parcel-cache
99
packages/examples/react-server-components/src/server.js
10-
packages/transformers/js/src/rsc-utils.js
1110
vendor
1211
tmp
1312
.parcel-cache

Cargo.lock

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2024"
88
napi = ["dep:napi", "dep:napi-derive", "dep:crossbeam-channel"]
99

1010
[dependencies]
11-
indexmap = {version = "1.9.2", features = ["serde"] }
11+
indexmap = "1.9.2"
1212
swc_core = { version = "21", features = [
1313
"common",
1414
"common_sourcemap",

packages/core/core/src/AssetGraph.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,22 +475,14 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
475475
}
476476
}
477477

478-
// If all of the assets are dependent (e.g. circular dependency),
479-
// make the first one the main resolved asset.
480-
let entryAssetId;
481-
if (assets.length > 1 && dependentAssetKeys.size === assets.length) {
482-
entryAssetId = assets[0].id;
483-
}
484-
485478
let assetObjects: Array<{|
486479
assetNodeId: NodeId,
487480
dependentAssets: Array<Asset>,
488481
|}> = [];
489482
let assetNodeIds = [];
490483
for (let asset of assets) {
491484
this.normalizeEnvironment(asset);
492-
let isDirect =
493-
asset.id === entryAssetId || !dependentAssetKeys.has(asset.uniqueKey);
485+
let isDirect = !dependentAssetKeys.has(asset.uniqueKey);
494486

495487
let dependentAssets = [];
496488
for (let dep of asset.dependencies.values()) {

packages/core/core/src/UncommittedAsset.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ export default class UncommittedAsset {
352352

353353
createChildAsset(
354354
result: TransformerResult,
355-
plugin?: PackageName,
356-
configPath?: ProjectPath,
355+
plugin: PackageName,
356+
configPath: ProjectPath,
357357
configKeyPath?: string,
358358
): UncommittedAsset {
359359
let content = result.content ?? null;

packages/core/core/src/public/Asset.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import type {
2020
MutableAssetSymbols as IMutableAssetSymbols,
2121
AssetSymbols as IAssetSymbols,
2222
BundleBehavior,
23-
TransformerResult,
2423
} from '@parcel/types';
2524
import type {Asset as AssetValue, ParcelOptions} from '../types';
2625

@@ -236,17 +235,6 @@ export class MutableAsset extends BaseAsset implements IMutableAsset {
236235
return this;
237236
}
238237

239-
createChildAsset(result?: TransformerResult): MutableAsset {
240-
let asset = this.#asset.createChildAsset(
241-
result || {
242-
type: this.#asset.value.type,
243-
},
244-
);
245-
asset.transformers = this.#asset.transformers;
246-
asset.sourceContent = this.#asset.sourceContent;
247-
return new MutableAsset(asset);
248-
}
249-
250238
setMap(map: ?SourceMap): void {
251239
this.#asset.setMap(map);
252240
}
@@ -300,7 +288,6 @@ export class MutableAsset extends BaseAsset implements IMutableAsset {
300288
);
301289
}
302290
this.#asset.value.uniqueKey = uniqueKey;
303-
this.#asset.updateId();
304291
}
305292

306293
get symbols(): IMutableAssetSymbols {

packages/core/integration-tests/test/javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3025,7 +3025,7 @@ describe('javascript', function () {
30253025
b.getBundles().find(b => b.type === 'js').filePath,
30263026
'utf8',
30273027
);
3028-
assert(dist.includes('$lodash = require("lodash");'));
3028+
assert(dist.includes('$eyi1T$lodash = require("lodash");'));
30293029

30303030
let add = await run(b);
30313031
assert.equal(add(2, 3), 5);

packages/core/integration-tests/test/react-server.js

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -312,77 +312,6 @@ describe('react server components', function () {
312312
assert.equal(v, 3);
313313
});
314314

315-
it('should support passing inline server references to the client', async function () {
316-
await fsFixture(overlayFS, dir)`
317-
index.jsx:
318-
import {Client} from './client';
319-
import {loadServerAction} from 'react-server-dom-parcel/server.edge';
320-
const root = 2;
321-
function Server({value}) {
322-
return <Client action={async arg => {
323-
"use server";
324-
return root + value + arg;
325-
}} />;
326-
}
327-
328-
async function runAction(id, args) {
329-
let action = await loadServerAction(id);
330-
return action(...args);
331-
}
332-
output = {Server, runAction};
333-
334-
client.jsx:
335-
"use client";
336-
export function Client() {
337-
return <p>Client</p>;
338-
}
339-
`;
340-
341-
let b = await bundle(path.join(dir, '/index.jsx'), {
342-
inputFS: overlayFS,
343-
targets: ['default'],
344-
defaultTargetOptions: {
345-
shouldScopeHoist,
346-
},
347-
});
348-
349-
let bundles = b.getBundles();
350-
assert.equal(bundles.length, 2);
351-
assert.equal(bundles[0].env.context, 'react-server');
352-
assert.equal(bundles[1].env.context, 'react-client');
353-
assertBundles(
354-
b,
355-
[
356-
{
357-
assets: ['index.jsx', 'index.jsx', 'rsc-utils.js'],
358-
},
359-
{
360-
assets: ['client.jsx'],
361-
},
362-
],
363-
{skipNodeModules: true},
364-
);
365-
366-
let res = (await run(b, null, {require: false})).output;
367-
let result = res.Server({value: 2});
368-
assert.equal(
369-
result.type.$$typeof,
370-
Symbol.for('react.client.reference'),
371-
);
372-
assert.equal(typeof result.props.action, 'function');
373-
assert.equal(
374-
result.props.action.$$typeof,
375-
Symbol.for('react.server.reference'),
376-
);
377-
assert.equal(typeof result.props.action.$$id, 'string');
378-
379-
let x = await res.runAction(result.props.action.$$id, [
380-
...result.props.action.$$bound,
381-
5,
382-
]);
383-
assert.equal(x, 9);
384-
});
385-
386315
it('should support "use server-entry"', async function () {
387316
await fsFixture(overlayFS, dir)`
388317
index.jsx:

packages/core/rust/index.d.ts

Lines changed: 75 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,98 @@
33

44
/* auto-generated by NAPI-RS */
55

6-
export declare function findAncestorFile(filenames: Array<string>, from: string, root: string): string | null
7-
export declare function findFirstFile(names: Array<string>): string | null
8-
export declare function findNodeModule(module: string, from: string): string | null
9-
export declare function hashString(s: string): string
10-
export declare function hashBuffer(buf: Buffer): string
11-
export declare function optimizeImage(kind: string, buf: Buffer): Buffer
12-
export declare function transformHtml(opts: object): unknown
13-
export declare function packageHtml(opts: object): unknown
14-
export declare function optimizeHtml(opts: object): unknown
15-
export declare function transformSvg(opts: object): unknown
16-
export declare function packageSvg(opts: object): unknown
17-
export declare function optimizeSvg(opts: object): unknown
18-
export declare function svgReact(opts: object): unknown
6+
export interface JsMacroError {
7+
kind: number;
8+
message: string;
9+
}
10+
export declare function findAncestorFile(
11+
filenames: Array<string>,
12+
from: string,
13+
root: string,
14+
): string | null;
15+
export declare function findFirstFile(names: Array<string>): string | null;
16+
export declare function findNodeModule(
17+
module: string,
18+
from: string,
19+
): string | null;
20+
export declare function hashString(s: string): string;
21+
export declare function hashBuffer(buf: Buffer): string;
22+
export declare function optimizeImage(kind: string, buf: Buffer): Buffer;
23+
export declare function transformHtml(opts: object): unknown;
24+
export declare function packageHtml(opts: object): unknown;
25+
export declare function optimizeHtml(opts: object): unknown;
26+
export declare function transformSvg(opts: object): unknown;
27+
export declare function packageSvg(opts: object): unknown;
28+
export declare function optimizeSvg(opts: object): unknown;
29+
export declare function svgReact(opts: object): unknown;
1930
export interface JsFileSystemOptions {
20-
read: (...args: any[]) => any
21-
readLink: (...args: any[]) => any
22-
kind: (...args: any[]) => any
23-
includeNodeModules?: NapiSideEffectsVariants
31+
read: (...args: any[]) => any;
32+
readLink: (...args: any[]) => any;
33+
kind: (...args: any[]) => any;
34+
includeNodeModules?: NapiSideEffectsVariants;
2435
}
2536
export interface FileSystem {
26-
fs?: JsFileSystemOptions
27-
includeNodeModules?: NapiSideEffectsVariants
28-
conditions?: number
29-
moduleDirResolver?: (...args: any[]) => any
30-
mode: number
31-
entries?: number
32-
extensions?: Array<string>
33-
packageExports: boolean
34-
typescript?: boolean
37+
fs?: JsFileSystemOptions;
38+
includeNodeModules?: NapiSideEffectsVariants;
39+
conditions?: number;
40+
moduleDirResolver?: (...args: any[]) => any;
41+
mode: number;
42+
entries?: number;
43+
extensions?: Array<string>;
44+
packageExports: boolean;
45+
typescript?: boolean;
3546
}
3647
export interface ResolveOptions {
37-
filename: string
38-
specifierType: string
39-
parent: string
40-
packageConditions?: Array<string>
48+
filename: string;
49+
specifierType: string;
50+
parent: string;
51+
packageConditions?: Array<string>;
4152
}
4253
export interface FilePathCreateInvalidation {
43-
filePath: string
54+
filePath: string;
4455
}
4556
export interface FileNameCreateInvalidation {
46-
fileName: string
47-
aboveFilePath: string
57+
fileName: string;
58+
aboveFilePath: string;
4859
}
4960
export interface GlobCreateInvalidation {
50-
glob: string
61+
glob: string;
5162
}
5263
export interface ResolveResult {
53-
resolution: unknown
54-
invalidateOnFileChange: Array<string>
55-
invalidateOnFileCreate: Array<FilePathCreateInvalidation | FileNameCreateInvalidation | GlobCreateInvalidation>
56-
query?: string
57-
sideEffects: boolean
58-
error: unknown
59-
moduleType: number
64+
resolution: unknown;
65+
invalidateOnFileChange: Array<string>;
66+
invalidateOnFileCreate: Array<
67+
| FilePathCreateInvalidation
68+
| FileNameCreateInvalidation
69+
| GlobCreateInvalidation
70+
>;
71+
query?: string;
72+
sideEffects: boolean;
73+
error: unknown;
74+
moduleType: number;
6075
}
6176
export interface JsInvalidations {
62-
invalidateOnFileChange: Array<string>
63-
invalidateOnFileCreate: Array<FilePathCreateInvalidation | FileNameCreateInvalidation | GlobCreateInvalidation>
64-
invalidateOnStartup: boolean
77+
invalidateOnFileChange: Array<string>;
78+
invalidateOnFileCreate: Array<
79+
| FilePathCreateInvalidation
80+
| FileNameCreateInvalidation
81+
| GlobCreateInvalidation
82+
>;
83+
invalidateOnStartup: boolean;
6584
}
66-
export declare function transform(opts: object): unknown
67-
export declare function transformAsync(opts: object): object
85+
export declare function transform(opts: object): unknown;
86+
export declare function transformAsync(opts: object): object;
6887
export declare class Hash {
69-
constructor()
70-
writeString(s: string): void
71-
writeBuffer(buf: Buffer): void
72-
finish(): string
88+
constructor();
89+
writeString(s: string): void;
90+
writeBuffer(buf: Buffer): void;
91+
finish(): string;
7392
}
7493
export declare class Resolver {
75-
constructor(projectRoot: string, options: FileSystem)
76-
resolve(options: ResolveOptions): ResolveResult
77-
resolveAsync(): object
78-
resolveAsync(options: ResolveOptions): object
79-
getInvalidations(path: string): JsInvalidations
80-
getInvalidations(path: string): JsInvalidations
94+
constructor(projectRoot: string, options: FileSystem);
95+
resolve(options: ResolveOptions): ResolveResult;
96+
resolveAsync(): object;
97+
resolveAsync(options: ResolveOptions): object;
98+
getInvalidations(path: string): JsInvalidations;
99+
getInvalidations(path: string): JsInvalidations;
81100
}

0 commit comments

Comments
 (0)