@meteorjs/rspack 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +13 -0
- package/index.js +4 -0
- package/package.json +1 -1
- package/plugins/HtmlRspackPlugin.js +28 -0
- package/plugins/RspackMeteorHtmlPlugin.js +1 -1
- package/rspack.config.js +2 -3
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
defineConfig as _rspackDefineConfig,
|
|
6
6
|
Configuration as _RspackConfig,
|
|
7
7
|
} from '@rspack/cli';
|
|
8
|
+
import { HtmlRspackPluginOptions } from '@rspack/core';
|
|
8
9
|
|
|
9
10
|
export interface MeteorRspackConfig extends _RspackConfig {
|
|
10
11
|
meteor?: {
|
|
@@ -34,3 +35,15 @@ export type ConfigFactory = (
|
|
|
34
35
|
export function defineConfig(
|
|
35
36
|
factory: ConfigFactory
|
|
36
37
|
): ReturnType<typeof _rspackDefineConfig>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A plugin that composes the original HtmlRspackPlugin from @rspack/core
|
|
41
|
+
* and RspackMeteorHtmlPlugin, in that order.
|
|
42
|
+
*/
|
|
43
|
+
export class HtmlRspackPlugin {
|
|
44
|
+
constructor(options?: HtmlRspackPluginOptions);
|
|
45
|
+
apply(compiler: any): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Re-export HtmlRspackPluginOptions from @rspack/cli
|
|
49
|
+
export { HtmlRspackPluginOptions };
|
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineConfig as rspackDefineConfig } from '@rspack/cli';
|
|
2
|
+
import HtmlRspackPlugin from './plugins/HtmlRspackPlugin.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @typedef {import('rspack').Configuration & {
|
|
@@ -21,3 +22,6 @@ export function defineConfig(factory) {
|
|
|
21
22
|
|
|
22
23
|
// Export our helper plus passthrough
|
|
23
24
|
export default defineConfig;
|
|
25
|
+
|
|
26
|
+
// Export the HtmlRspackPlugin
|
|
27
|
+
export { HtmlRspackPlugin };
|
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import RspackMeteorHtmlPlugin, { loadHtmlRspackPluginFromHost } from './RspackMeteorHtmlPlugin.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A plugin that composes the original HtmlRspackPlugin from @rspack/core
|
|
5
|
+
* and RspackMeteorHtmlPlugin, in that order.
|
|
6
|
+
*/
|
|
7
|
+
export default class HtmlRspackPlugin {
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply(compiler) {
|
|
13
|
+
// Load the original HtmlRspackPlugin from the host project
|
|
14
|
+
const OriginalHtmlRspackPlugin = loadHtmlRspackPluginFromHost(compiler);
|
|
15
|
+
|
|
16
|
+
if (!OriginalHtmlRspackPlugin) {
|
|
17
|
+
throw new Error('Could not load HtmlRspackPlugin from host project.');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Apply the original HtmlRspackPlugin
|
|
21
|
+
const originalPlugin = new OriginalHtmlRspackPlugin(this.options);
|
|
22
|
+
originalPlugin.apply(compiler);
|
|
23
|
+
|
|
24
|
+
// Apply the RspackMeteorHtmlPlugin
|
|
25
|
+
const meteorPlugin = new RspackMeteorHtmlPlugin();
|
|
26
|
+
meteorPlugin.apply(compiler);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
|
|
4
|
-
function loadHtmlRspackPluginFromHost(compiler) {
|
|
4
|
+
export function loadHtmlRspackPluginFromHost(compiler) {
|
|
5
5
|
// Prefer the compiler's context; fall back to process.cwd()
|
|
6
6
|
const ctx = compiler.options?.context || compiler.context || process.cwd();
|
|
7
7
|
const requireFromHost = createRequire(path.join(ctx, 'package.json'));
|
package/rspack.config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DefinePlugin, BannerPlugin
|
|
1
|
+
import { DefinePlugin, BannerPlugin } from '@rspack/core';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
4
|
import path from 'path';
|
|
@@ -9,7 +9,7 @@ import { RequireExternalsPlugin } from './plugins/RequireExtenalsPlugin.js';
|
|
|
9
9
|
import { getMeteorAppSwcConfig } from "./lib/swc.js";
|
|
10
10
|
import { mergeSplitOverlap } from './lib/mergeRulesSplitOverlap.js';
|
|
11
11
|
import CleanBuildAssetsPlugin from "./plugins/CleanBuildAssetsPlugin.js";
|
|
12
|
-
import
|
|
12
|
+
import HtmlRspackPlugin from './plugins/HtmlRspackPlugin.js';
|
|
13
13
|
|
|
14
14
|
const require = createRequire(import.meta.url);
|
|
15
15
|
|
|
@@ -308,7 +308,6 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
308
308
|
</body>
|
|
309
309
|
`,
|
|
310
310
|
}),
|
|
311
|
-
new RspackMeteorHtmlPlugin(),
|
|
312
311
|
],
|
|
313
312
|
watchOptions,
|
|
314
313
|
devtool: isDevEnvironment || isTest ? 'source-map' : 'hidden-source-map',
|