Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .github/workflows/main.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test

on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: Setup Node.js
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 24.19.0
package-manager-cache: false

- name: Install Pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
with:
run_install: true

- name: Run Test
run: node --run test
Comment thread
chenjiahan marked this conversation as resolved.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
/dist/
/coverage/
/examples/*/dist/
npm-debug.*.log
yarn.lock
package-lock.json
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Custom Template | [custom-template](./custom-template)
Custom Script / Link tag position | [custom-insertion-point](./custom-insertion-position)
Default | [default](./default)
Favicon | [favicon](./favicon.)
Html Loader | [html-loader](./html-loader)
HTML Template | [html-loader](./html-loader)
Inline | [inline](./inline)
Javascript-advanced | [javascript-advanced](./javascript-advanced)
Javascript | [javascript](./javascript)
Expand Down
54 changes: 0 additions & 54 deletions examples/build-examples.js

This file was deleted.

54 changes: 54 additions & 0 deletions examples/build-examples.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { readdir, rm } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { rspack, rspackVersion } from '@rspack/core';

const examplesDirectory = fileURLToPath(new URL('.', import.meta.url));
const rspackMajorVersion = rspackVersion.split('.')[0];
const examples = (await readdir(examplesDirectory, { withFileTypes: true }))
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name);

async function buildExample(exampleName) {
const examplePath = path.join(examplesDirectory, exampleName);
const configUrl = pathToFileURL(path.join(examplePath, 'rspack.config.mjs'));
const { default: config } = await import(configUrl.href);

config.mode = 'production';
config.optimization = config.optimization || {};
config.optimization.minimizer = [];

await rm(path.join(examplePath, 'dist', `rspack-${rspackMajorVersion}`), {
force: true,
recursive: true,
});

return new Promise((resolve, reject) => {
rspack(config, (error, stats) => {
if (error) {
reject(error);
return;
}

if (!stats || stats.hasErrors()) {
reject(
new Error(
stats
? stats.toString({ colors: true })
: 'Rspack did not return compilation stats.',
),
);
return;
}

resolve();
});
});
}

try {
await Promise.all(examples.map(buildExample));
} catch (error) {
console.error(error);
process.exitCode = 1;
}
Loading