Skip to content

Commit 9b5c5e2

Browse files
fix: esbuild doesnt allow property mutation on options
1 parent eac0377 commit 9b5c5e2

File tree

7 files changed

+22
-93
lines changed

7 files changed

+22
-93
lines changed

packages/docs/src/routes/api/qwik-optimizer/api.json

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -479,24 +479,10 @@
479479
}
480480
],
481481
"kind": "TypeAlias",
482-
"content": "```typescript\nexport type QwikEsbuildPlugin = Plugin & {\n api: QwikEsbuildPluginApi;\n};\n```\n**References:** [QwikEsbuildPluginApi](#qwikesbuildpluginapi)",
482+
"content": "```typescript\nexport type QwikEsbuildPlugin = Plugin;\n```",
483483
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/optimizer/src/plugins/esbuild.ts",
484484
"mdFile": "qwik.qwikesbuildplugin.md"
485485
},
486-
{
487-
"name": "QwikEsbuildPluginApi",
488-
"id": "qwikesbuildpluginapi",
489-
"hierarchy": [
490-
{
491-
"name": "QwikEsbuildPluginApi",
492-
"id": "qwikesbuildpluginapi"
493-
}
494-
],
495-
"kind": "TypeAlias",
496-
"content": "```typescript\nexport type QwikEsbuildPluginApi = {\n getOptimizer: () => Optimizer;\n getOptions: () => NormalizedQwikPluginOptions;\n};\n```\n**References:** [Optimizer](#optimizer)",
497-
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/optimizer/src/plugins/esbuild.ts",
498-
"mdFile": "qwik.qwikesbuildpluginapi.md"
499-
},
500486
{
501487
"name": "QwikEsbuildPluginOptions",
502488
"id": "qwikesbuildpluginoptions",

packages/docs/src/routes/api/qwik-optimizer/index.mdx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,26 +1492,9 @@ Plugin
14921492
## QwikEsbuildPlugin
14931493

14941494
```typescript
1495-
export type QwikEsbuildPlugin = Plugin & {
1496-
api: QwikEsbuildPluginApi;
1497-
};
1498-
```
1499-
1500-
**References:** [QwikEsbuildPluginApi](#qwikesbuildpluginapi)
1501-
1502-
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/optimizer/src/plugins/esbuild.ts)
1503-
1504-
## QwikEsbuildPluginApi
1505-
1506-
```typescript
1507-
export type QwikEsbuildPluginApi = {
1508-
getOptimizer: () => Optimizer;
1509-
getOptions: () => NormalizedQwikPluginOptions;
1510-
};
1495+
export type QwikEsbuildPlugin = Plugin;
15111496
```
15121497

1513-
**References:** [Optimizer](#optimizer)
1514-
15151498
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/optimizer/src/plugins/esbuild.ts)
15161499

15171500
## QwikEsbuildPluginOptions

packages/qwik/src/optimizer/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ export type {
4242

4343
export type { ExperimentalFeatures, QwikBuildMode, QwikBuildTarget } from './plugins/plugin';
4444
export type { QwikRollupPluginOptions } from './plugins/rollup';
45-
export type {
46-
QwikEsbuildPluginOptions,
47-
QwikEsbuildPlugin,
48-
QwikEsbuildPluginApi,
49-
} from './plugins/esbuild';
45+
export type { QwikEsbuildPluginOptions, QwikEsbuildPlugin } from './plugins/esbuild';
5046
export type {
5147
QwikViteDevResponse,
5248
QwikVitePlugin,

packages/qwik/src/optimizer/src/plugins/esbuild.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { Plugin, PluginBuild } from 'esbuild';
22
import type {
33
EntryStrategy,
4-
Optimizer,
54
OptimizerOptions,
65
QwikManifest,
76
TransformModule,
@@ -10,18 +9,11 @@ import type {
109
import {
1110
createQwikPlugin,
1211
type ExperimentalFeatures,
13-
type NormalizedQwikPluginOptions,
1412
type QwikBuildMode,
1513
type QwikBuildTarget,
1614
type QwikPluginOptions,
1715
} from './plugin';
1816

19-
/** @public */
20-
export type QwikEsbuildPluginApi = {
21-
getOptimizer: () => Optimizer;
22-
getOptions: () => NormalizedQwikPluginOptions;
23-
};
24-
2517
/** @public */
2618
export function qwikEsbuild(qwikEsbuildOpts: QwikEsbuildPluginOptions = {}): Plugin {
2719
const qwikPlugin = createQwikPlugin(qwikEsbuildOpts.optimizerOptions);
@@ -205,12 +197,6 @@ export function qwikEsbuild(qwikEsbuildOpts: QwikEsbuildPluginOptions = {}): Plu
205197
},
206198
};
207199

208-
// Add API methods to the plugin
209-
(esbuildPlugin as any).api = {
210-
getOptimizer: () => qwikPlugin.getOptimizer(),
211-
getOptions: () => qwikPlugin.getOptions(),
212-
};
213-
214200
return esbuildPlugin;
215201
}
216202

@@ -363,4 +349,4 @@ export interface QwikEsbuildPluginOptions {
363349
export { ExperimentalFeatures } from './plugin';
364350

365351
/** @public */
366-
export type QwikEsbuildPlugin = Plugin & { api: QwikEsbuildPluginApi };
352+
export type QwikEsbuildPlugin = Plugin;

packages/qwik/src/optimizer/src/plugins/esbuild.unit.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,17 @@ test('esbuild plugin creation', async () => {
2727

2828
assert.equal(plugin.name, 'esbuild-plugin-qwik');
2929
assert.equal(typeof plugin.setup, 'function');
30-
assert.equal(typeof (plugin as any).api, 'object');
31-
});
32-
33-
test('esbuild plugin api methods', async () => {
34-
const initOpts: QwikEsbuildPluginOptions = {
35-
optimizerOptions: mockOptimizerOptions(),
36-
};
37-
const plugin = qwikEsbuild(initOpts);
38-
const api = (plugin as any).api;
39-
40-
assert.equal(typeof api.getOptimizer, 'function');
41-
assert.equal(typeof api.getOptions, 'function');
4230
});
4331

4432
test('esbuild default options, client', async () => {
4533
const initOpts: QwikEsbuildPluginOptions = {
4634
optimizerOptions: mockOptimizerOptions(),
4735
};
4836
const plugin = qwikEsbuild(initOpts);
49-
const api = (plugin as any).api;
50-
51-
// The plugin needs to be initialized to get options
52-
// In a real scenario, this would happen during the setup phase
53-
try {
54-
const options = api.getOptions();
55-
// Options won't be available until the plugin is initialized
56-
assert.equal(options.target, 'client');
57-
} catch (error) {
58-
// Expected since plugin isn't initialized yet
59-
assert.equal((error as Error).message, 'Qwik plugin has not been initialized');
60-
}
37+
38+
// Plugin should be created successfully with default options
39+
assert.equal(plugin.name, 'esbuild-plugin-qwik');
40+
assert.equal(typeof plugin.setup, 'function');
6141
});
6242

6343
test('esbuild options, ssr target', async () => {
@@ -212,8 +192,6 @@ describe('esbuild plugin integration', () => {
212192
assert.equal(plugin.name, 'esbuild-plugin-qwik');
213193

214194
// The plugin should be created successfully with all options
215-
const api = (plugin as any).api;
216-
assert.equal(typeof api.getOptimizer, 'function');
217-
assert.equal(typeof api.getOptions, 'function');
195+
assert.equal(typeof plugin.setup, 'function');
218196
});
219197
});

packages/qwik/src/optimizer/src/qwik-binding-map.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,15 @@ export const QWIK_BINDING_MAP = {
3030
"platformArchABI": "qwik.win32-x64-msvc.node"
3131
}
3232
]
33+
},
34+
"linux": {
35+
"x64": [
36+
{
37+
"platform": "linux",
38+
"arch": "x64",
39+
"abi": "gnu",
40+
"platformArchABI": "qwik.linux-x64-gnu.node"
41+
}
42+
]
3343
}
3444
};

packages/qwik/src/optimizer/src/qwik.optimizer.api.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,7 @@ export type QwikBundleGraph = Array<string | number>;
191191
export function qwikEsbuild(qwikEsbuildOpts?: QwikEsbuildPluginOptions): Plugin_2;
192192

193193
// @public (undocumented)
194-
export type QwikEsbuildPlugin = Plugin_2 & {
195-
api: QwikEsbuildPluginApi;
196-
};
197-
198-
// @public (undocumented)
199-
export type QwikEsbuildPluginApi = {
200-
getOptimizer: () => Optimizer;
201-
getOptions: () => NormalizedQwikPluginOptions;
202-
};
194+
export type QwikEsbuildPlugin = Plugin_2;
203195

204196
// @public (undocumented)
205197
export interface QwikEsbuildPluginOptions {
@@ -338,6 +330,8 @@ export interface QwikVitePluginApi {
338330
getManifest: () => QwikManifest | null;
339331
// (undocumented)
340332
getOptimizer: () => Optimizer | null;
333+
// Warning: (ae-forgotten-export) The symbol "NormalizedQwikPluginOptions" needs to be exported by the entry point index.d.ts
334+
//
341335
// (undocumented)
342336
getOptions: () => NormalizedQwikPluginOptions;
343337
// (undocumented)
@@ -550,10 +544,6 @@ export const versions: {
550544
qwik: string;
551545
};
552546

553-
// Warnings were encountered during analysis:
554-
//
555-
// /Users/jackshelton/dev/open-source/qwik/dist-dev/dts-out/packages/qwik/src/optimizer/src/plugins/esbuild.d.ts:7:5 - (ae-forgotten-export) The symbol "NormalizedQwikPluginOptions" needs to be exported by the entry point index.d.ts
556-
557547
// (No @packageDocumentation comment for this package)
558548

559549
```

0 commit comments

Comments
 (0)