Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const { rspack } = require('@rspack/core');
const { ReactRefreshRspackPlugin } = require('@rspack/plugin-react-refresh');
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
// @ts-check

import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';
import { ReactRefreshRspackPlugin } from '@rspack/plugin-react-refresh';

/** @type {import('@rspack/cli').Configuration} */
module.exports = {
export default defineConfig({
entry: {
main: './src/index.tsx',
},
Expand Down Expand Up @@ -54,4 +57,4 @@ module.exports = {
experiments: {
css: true,
},
};
});
5 changes: 1 addition & 4 deletions rspack/basic-ts/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// @ts-check
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export default defineConfig({
entry: './src/index.ts',
resolve: {
tsConfig: {
configFile: path.resolve(__dirname, 'tsconfig.json'),
configFile: path.resolve(import.meta.dirname, 'tsconfig.json'),
},
extensions: ['...', '.ts'],
},
Expand Down
7 changes: 2 additions & 5 deletions rspack/builtin-swc-loader/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// @ts-check

import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const require = createRequire(import.meta.url);
const isProduction = process.env.NODE_ENV === 'production';

export default defineConfig({
Expand All @@ -17,7 +14,7 @@ export default defineConfig({
resolve: {
extensions: ['...', '.jsx'],
alias: {
'@swc/helpers': path.dirname(require.resolve('@swc/helpers/package.json')),
'@swc/helpers': path.dirname(fileURLToPath(import.meta.resolve('@swc/helpers/package.json'))),
},
},
module: {
Expand Down Expand Up @@ -56,7 +53,7 @@ export default defineConfig({
[
'@swc/plugin-relay',
{
rootDir: __dirname,
rootDir: import.meta.dirname,
artifactDirectory: 'src/__generated__',
language: 'typescript',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { rspack } = require('@rspack/core');
const { ReactRefreshRspackPlugin } = require('@rspack/plugin-react-refresh');
// @ts-check

import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';
import { ReactRefreshRspackPlugin } from '@rspack/plugin-react-refresh';
/** @type {import('@rspack/cli').Configuration} */
const config = {
export default defineConfig({
entry: {
main: './src/index.tsx',
},
Expand Down Expand Up @@ -55,5 +58,4 @@ const config = {
],
}),
],
};
module.exports = config;
});
12 changes: 7 additions & 5 deletions rspack/cra/rspack.config.js → rspack/cra/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const { rspack } = require('@rspack/core');
const { ReactRefreshRspackPlugin } = require('@rspack/plugin-react-refresh');
// @ts-check

import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';
import { ReactRefreshRspackPlugin } from '@rspack/plugin-react-refresh';

/** @type {import('@rspack/cli').Configuration} */
const config = {
export default defineConfig({
entry: {
main: './src/index.jsx',
},
Expand Down Expand Up @@ -56,5 +59,4 @@ const config = {
],
}),
],
};
module.exports = config;
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { rspack } = require('@rspack/core');
// @ts-check

import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';

/** @type {import('@rspack/cli').Configuration} */
const config = {
export default defineConfig({
entry: './src/index.js',
module: {
rules: [
Expand All @@ -27,6 +30,4 @@ const config = {
minSize: 0,
},
},
};

module.exports = config;
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const path = require('path');
const { rspack } = require('@rspack/core');
// @ts-check

import path from 'node:path';
import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';

/** @type {import('@rspack/cli').Configuration} */
const config = {
export default defineConfig({
entry: './src/index.js',
module: {
parser: {
Expand All @@ -19,12 +22,12 @@ const config = {
rules: [
{
test: /\.css$/,
exclude: path.resolve(__dirname, 'src/legacy'),
exclude: path.resolve(import.meta.dirname, 'src/legacy'),
type: 'css/auto',
},
{
// files in src/legacy and ends with .css will be CSS Modules
include: path.resolve(__dirname, 'src/legacy'),
include: path.resolve(import.meta.dirname, 'src/legacy'),
test: /\.css$/,
type: 'css/module',
parser: {
Expand All @@ -47,6 +50,4 @@ const config = {
template: './index.html',
}),
],
};

module.exports = config;
});
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
const { rspack } = require('@rspack/core');
const path = require('node:path');
// @ts-check

import path from 'node:path';
import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';

/** @type {import('@rspack/cli').Configuration} */
const config = {
export default defineConfig({
entry: './index',
output: {
path: path.resolve(__dirname, 'dist'),
path: path.resolve(import.meta.dirname, 'dist'),
},
resolve: {
extensions: ['...', '.ts', '.tsx', '.js', '.jsx'],
},
plugins: [
new rspack.DllReferencePlugin({
manifest: path.resolve(__dirname, '../dll/dist/alpha.manifest.json'),
manifest: path.resolve(import.meta.dirname, '../dll/dist/alpha.manifest.json'),
extensions: ['.js', '.ts'],
}),
new rspack.DllReferencePlugin({
manifest: path.resolve(__dirname, '../dll/dist/beta.manifest.json'),
manifest: path.resolve(import.meta.dirname, '../dll/dist/beta.manifest.json'),
scope: 'beta',
extensions: ['.js', '.jsx', '.ts', '.tsx'],
}),
],
mode: 'development',
};

module.exports = config;
});
17 changes: 9 additions & 8 deletions rspack/dll/rspack.config.js → rspack/dll/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const { rspack } = require('@rspack/core');
const path = require('node:path');
// @ts-check

import path from 'node:path';
import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';

/** @type {import('@rspack/cli').Configuration} */
const config = {
export default defineConfig({
resolve: {
extensions: ['...', '.ts', '.tsx', '.js', '.jsx'],
},
Expand All @@ -11,16 +14,14 @@ const config = {
beta: ['./beta', './b', './c'],
},
output: {
path: path.resolve(__dirname, 'dist'),
path: path.resolve(import.meta.dirname, 'dist'),
filename: '[name].dll.js',
library: '[name]_dll_lib',
},
plugins: [
new rspack.DllPlugin({
path: path.join(__dirname, 'dist', '[name].manifest.json'),
path: path.join(import.meta.dirname, 'dist', '[name].manifest.json'),
name: '[name]_dll_lib',
}),
],
};

module.exports = config;
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const { rspack } = require('@rspack/core');
// @ts-check

import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';
/** @type {import('@rspack/cli').Configuration} */
const config = {
export default defineConfig({
entry: {
main: './src/index.jsx',
},
Expand Down Expand Up @@ -36,5 +39,4 @@ const config = {
},
],
},
};
module.exports = config;
});
2 changes: 1 addition & 1 deletion rspack/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "rspack build",
"dev": "rspack serve -c",
"dev:loader": "rspack serve -c rspack.config.loader.js"
"dev:loader": "rspack serve -c rspack.config.loader.mjs"
},
"devDependencies": {
"@rspack/cli": "2.0.0-rc.1",
Expand Down
10 changes: 0 additions & 10 deletions rspack/eslint/rspack.config.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// @ts-check

import { defineConfig } from '@rspack/cli';
/** @type {import('@rspack/cli').Configuration} */
const config = {
context: __dirname,
export default defineConfig({
context: import.meta.dirname,
entry: {
main: './src/index.js',
},
Expand All @@ -18,5 +21,4 @@ const config = {
},
],
},
};
module.exports = config;
});
12 changes: 12 additions & 0 deletions rspack/eslint/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @ts-check

import { defineConfig } from '@rspack/cli';
import EslintPlugin from 'eslint-rspack-plugin';
/** @type {import('@rspack/cli').Configuration} */
export default defineConfig({
context: import.meta.dirname,
entry: {
main: './src/index.js',
},
plugins: [new EslintPlugin()],
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin');
// @ts-check

import { defineConfig } from '@rspack/cli';
import { RunScriptWebpackPlugin } from 'run-script-webpack-plugin';

/** @type {import('@rspack/cli').Configuration} */
const config = {
context: __dirname,
export default defineConfig({
context: import.meta.dirname,
target: 'node',
entry: {
main: ['@rspack/core/hot/poll?100', './src/main.ts'],
Expand Down Expand Up @@ -44,5 +47,4 @@ const config = {
writeToDisk: true,
},
},
};
module.exports = config;
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { rspack } = require('@rspack/core');
// @ts-check

import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';
/** @type {import('@rspack/cli').Configuration} */
const config = {
context: __dirname,
export default defineConfig({
context: import.meta.dirname,
entry: {
main: './src/index.js',
},
Expand All @@ -13,5 +16,4 @@ const config = {
extractComments: true,
}),
],
};
module.exports = config;
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { defineConfig } = require('@rspack/cli');
const GeneratePackageJsonPlugin = require('generate-package-json-webpack-plugin');
// @ts-check

import { defineConfig } from '@rspack/cli';
import GeneratePackageJsonPlugin from 'generate-package-json-webpack-plugin';

const basePackage = {
name: 'my-module',
Expand All @@ -10,6 +12,6 @@ const basePackage = {
},
};

module.exports = defineConfig({
export default defineConfig({
plugins: [new GeneratePackageJsonPlugin(basePackage, {})],
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const { rspack } = require('@rspack/core');
// @ts-check

import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';
/** @type {import('@rspack/cli').Configuration} */
const config = {
export default defineConfig({
entry: './src/index.js',
plugins: [
new rspack.HtmlRspackPlugin({
Expand All @@ -20,5 +23,4 @@ const config = {
},
},
],
};
module.exports = config;
});
Loading
Loading