@meteorjs/rspack 1.0.0 → 1.0.2
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/.claude/settings.local.json +10 -0
- package/README.md +141 -0
- package/package.json +8 -1
- package/scripts/bump-version.js +89 -0
- package/scripts/publish-beta.sh +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# @meteorjs/rspack
|
|
2
|
+
|
|
3
|
+
The default [Rspack](https://rspack.dev) configuration for Meteor applications. This package provides everything you need to bundle your Meteor app with Rspack out of the box: client and server builds, SWC transpilation, React/Blaze/Angular support, hot module replacement, asset management, and all the Meteor-specific wiring so you don't have to.
|
|
4
|
+
|
|
5
|
+
When Meteor runs with the Rspack bundler enabled, this package is what generates the underlying Rspack configuration. It detects your project setup (TypeScript, React, Blaze, Angular), sets up the right loaders and plugins, defines `Meteor.isClient`/`Meteor.isServer` and friends, configures caching, and exposes a set of helpers you can use in your own `rspack.config.js` to customize the build without breaking Meteor integration.
|
|
6
|
+
|
|
7
|
+
## What it provides
|
|
8
|
+
|
|
9
|
+
- **Dual client/server builds** with the correct targets, externals, and output paths
|
|
10
|
+
- **SWC-based transpilation** for JS/TS/JSX/TSX with automatic framework detection
|
|
11
|
+
- **React Fast Refresh** in development when React is enabled
|
|
12
|
+
- **Blaze template handling** via ignore-loader when Blaze is enabled
|
|
13
|
+
- **Persistent filesystem caching** for fast rebuilds
|
|
14
|
+
- **Asset externals and HTML generation** through custom Rspack plugins
|
|
15
|
+
- **A `defineConfig` helper** that accepts a factory function receiving Meteor environment flags and build utilities
|
|
16
|
+
- **Customizable config** via `rspack.config.js` in your project root, with safe merging that warns if you try to override reserved settings
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
[Rspack integration](https://docs.meteor.com/about/modern-build-stack/rspack-bundler-integration.html) is automatically managed by the rspack Atmosphere package.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
meteor add rspack
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
By doing this, your Meteor app will automatically serve `@meteorjs/rspack` and the required `@rspack/cli`, `@rspack/core`, among others.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
In your project's `rspack.config.js`, use the `defineConfig` helper to customize the build. The factory function receives a `env` object with Meteor environment flags and helper utilities:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const { defineConfig } = require('@meteorjs/rspack');
|
|
34
|
+
|
|
35
|
+
module.exports = defineConfig((env, argv) => {
|
|
36
|
+
// env.isClient, env.isServer, env.isDevelopment, env.isProduction
|
|
37
|
+
// env.isReactEnabled, env.isBlazeEnabled, etc.
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
// Your custom Rspack configuration here.
|
|
41
|
+
// It gets safely merged with the Meteor defaults.
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
More information is available in the official docs: [Rspack Bundler Integration](https://docs.meteor.com/about/modern-build-stack/rspack-bundler-integration.html#custom-rspack-config-js).
|
|
47
|
+
|
|
48
|
+
## Development
|
|
49
|
+
|
|
50
|
+
### Install dependencies
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Version bumping
|
|
57
|
+
|
|
58
|
+
Use `npm run bump` to update the version in `package.json` before publishing.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm run bump -- <major|minor|patch> [--beta]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Standard bumps** increment the version and remove any prerelease suffix:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm run bump -- patch # 1.0.1 -> 1.0.2
|
|
68
|
+
npm run bump -- minor # 1.0.1 -> 1.1.0
|
|
69
|
+
npm run bump -- major # 1.0.1 -> 2.0.0
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Beta bumps** append or increment a `-beta.N` prerelease suffix:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm run bump -- patch --beta # 1.0.1 -> 1.0.2-beta.0
|
|
76
|
+
npm run bump -- patch --beta # 1.0.2-beta.0 -> 1.0.2-beta.1
|
|
77
|
+
npm run bump -- patch --beta # 1.0.2-beta.1 -> 1.0.2-beta.2
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If you change the bump level while on a beta, the base version updates and the beta counter resets:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm run bump -- minor --beta # 1.0.2-beta.2 -> 1.1.0-beta.0
|
|
84
|
+
npm run bump -- major --beta # 1.1.0-beta.0 -> 2.0.0-beta.0
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Publishing a beta release
|
|
88
|
+
|
|
89
|
+
After bumping to a beta version, publish to the `beta` dist-tag:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm run bump -- patch --beta
|
|
93
|
+
npm run publish:beta
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Users can then install the beta with:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm install @meteorjs/rspack@beta
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
You can pass extra flags to `npm publish` through the script:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm run publish:beta -- --dry-run
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Publishing an official release
|
|
109
|
+
|
|
110
|
+
After bumping to a stable version, publish with the default `latest` tag:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm run bump -- patch
|
|
114
|
+
npm publish
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Typical workflows
|
|
118
|
+
|
|
119
|
+
**Beta iteration**: ship multiple beta builds for the same upcoming patch:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm run bump -- patch --beta # 1.0.1 -> 1.0.2-beta.0
|
|
123
|
+
npm run publish:beta
|
|
124
|
+
# ... fix issues ...
|
|
125
|
+
npm run bump -- patch --beta # 1.0.2-beta.0 -> 1.0.2-beta.1
|
|
126
|
+
npm run publish:beta
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Promote beta to stable**: once the beta is ready, bump to the stable version and publish:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm run bump -- patch # 1.0.2-beta.1 -> 1.0.3
|
|
133
|
+
npm publish
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Direct stable release**: skip the beta phase entirely:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm run bump -- minor # 1.0.1 -> 1.1.0
|
|
140
|
+
npm publish
|
|
141
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meteorjs/rspack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Configuration logic for using Rspack in Meteor projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -12,8 +12,15 @@
|
|
|
12
12
|
"node-polyfill-webpack-plugin": "^4.1.0",
|
|
13
13
|
"webpack-merge": "^6.0.1"
|
|
14
14
|
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"bump": "node ./scripts/bump-version.js",
|
|
17
|
+
"publish:beta": "bash ./scripts/publish-beta.sh"
|
|
18
|
+
},
|
|
15
19
|
"peerDependencies": {
|
|
16
20
|
"@rspack/cli": ">=1.3.0",
|
|
17
21
|
"@rspack/core": ">=1.3.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"semver": "^7.7.4"
|
|
18
25
|
}
|
|
19
26
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const semver = require('semver');
|
|
7
|
+
|
|
8
|
+
const VALID_LEVELS = ['major', 'minor', 'patch'];
|
|
9
|
+
|
|
10
|
+
function usage() {
|
|
11
|
+
console.log(`Usage: node ${path.basename(__filename)} <major|minor|patch> [--beta]`);
|
|
12
|
+
console.log('');
|
|
13
|
+
console.log('Examples:');
|
|
14
|
+
console.log(' patch # 1.0.1 -> 1.0.2');
|
|
15
|
+
console.log(' minor # 1.0.1 -> 1.1.0');
|
|
16
|
+
console.log(' major # 1.0.1 -> 2.0.0');
|
|
17
|
+
console.log(' patch --beta # 1.0.1 -> 1.0.2-beta.0');
|
|
18
|
+
console.log(' patch --beta # 1.0.2-beta.0 -> 1.0.2-beta.1 (already beta, bumps beta number)');
|
|
19
|
+
console.log(' minor --beta # 1.0.2-beta.1 -> 1.1.0-beta.0 (different bump level resets)');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const args = process.argv.slice(2);
|
|
24
|
+
const level = args[0];
|
|
25
|
+
const beta = args.includes('--beta');
|
|
26
|
+
|
|
27
|
+
if (!level || !VALID_LEVELS.includes(level)) {
|
|
28
|
+
if (level) console.error(`Error: first argument must be major, minor, or patch`);
|
|
29
|
+
usage();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const pkgPath = path.resolve(__dirname, '..', 'package.json');
|
|
33
|
+
const raw = fs.readFileSync(pkgPath, 'utf8');
|
|
34
|
+
const pkg = JSON.parse(raw);
|
|
35
|
+
const current = pkg.version;
|
|
36
|
+
const parsed = semver.parse(current);
|
|
37
|
+
|
|
38
|
+
if (!parsed) {
|
|
39
|
+
console.error(`Error: invalid current version "${current}"`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let newVersion;
|
|
44
|
+
|
|
45
|
+
if (beta) {
|
|
46
|
+
const isBeta = parsed.prerelease.length > 0 && parsed.prerelease[0] === 'beta';
|
|
47
|
+
|
|
48
|
+
if (isBeta) {
|
|
49
|
+
// Already a beta. The base version already has a prior bump applied.
|
|
50
|
+
// Check if the same bump level is being requested by inspecting which
|
|
51
|
+
// components are zeroed out (major resets minor+patch, minor resets patch).
|
|
52
|
+
// If the same level, just increment the beta number.
|
|
53
|
+
const { major, minor, patch } = parsed;
|
|
54
|
+
const betaNum = typeof parsed.prerelease[1] === 'number' ? parsed.prerelease[1] : 0;
|
|
55
|
+
let sameLevel = false;
|
|
56
|
+
|
|
57
|
+
if (level === 'patch') {
|
|
58
|
+
sameLevel = true;
|
|
59
|
+
} else if (level === 'minor') {
|
|
60
|
+
sameLevel = patch === 0 && minor > 0;
|
|
61
|
+
} else if (level === 'major') {
|
|
62
|
+
sameLevel = minor === 0 && patch === 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (sameLevel) {
|
|
66
|
+
newVersion = `${major}.${minor}.${patch}-beta.${betaNum + 1}`;
|
|
67
|
+
} else {
|
|
68
|
+
const bumped = semver.inc(`${major}.${minor}.${patch}`, level);
|
|
69
|
+
newVersion = `${bumped}-beta.0`;
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
// Not a beta yet: bump the base and start at beta.0
|
|
73
|
+
const bumped = semver.inc(current, level);
|
|
74
|
+
newVersion = `${bumped}-beta.0`;
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
if (parsed.prerelease.length > 0) {
|
|
78
|
+
// Currently a prerelease: bump base version from the clean base
|
|
79
|
+
const cleanBase = `${parsed.major}.${parsed.minor}.${parsed.patch}`;
|
|
80
|
+
newVersion = semver.inc(cleanBase, level);
|
|
81
|
+
} else {
|
|
82
|
+
newVersion = semver.inc(current, level);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
pkg.version = newVersion;
|
|
87
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
88
|
+
|
|
89
|
+
console.log(`Bumped version: ${current} -> ${newVersion}`);
|