Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(build): switch to Rslib #15

Merged
merged 1 commit into from
Nov 11, 2024
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
3 changes: 0 additions & 3 deletions client/package.json

This file was deleted.

10 changes: 10 additions & 0 deletions index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Compatible with CommonJS
* ```js
* const { PreactRefreshRspackPlugin } = require('@rspack/plugin-preact-refresh');
* ```
*/

const { PreactRefreshRspackPlugin } = require('./dist/index.cjs');

module.exports = PreactRefreshRspackPlugin;
File renamed without changes.
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
"version": "1.1.1",
"repository": "https://github.com/rspack-contrib/rspack-plugin-preact-refresh",
"license": "MIT",
"description": "Preact refresh plugin for rspack",
"main": "dist/index.js",
"description": "Preact refresh plugin for Rspack",
"type": "module",
"main": "index.cjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"default": "./dist/index.js"
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./index.cjs"
},
"./intercept": "./client/reactRefresh.js",
"./prefresh": "./client/prefresh.js",
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc -b ./tsconfig.build.json",
"dev": "tsc -b -w",
"build": "rslib build",
"dev": "rslib build --watch",
"lint": "biome check .",
"lint:write": "biome check . --write",
"prepare": "simple-git-hooks && npm run build",
"test": "cross-env RSPACK_HOT_TEST=true jest --colors",
"testu": "cross-env RSPACK_HOT_TEST=true jest --colors --updateSnapshot",
"release": "node ./scripts/release.mjs"
},
"files": [
"client",
"dist"
],
"files": ["client", "dist", "index.cjs"],
"simple-git-hooks": {
"pre-commit": "npx nano-staged"
},
Expand All @@ -40,12 +40,13 @@
"@biomejs/biome": "^1.9.4",
"@prefresh/core": "^1.5.2",
"@prefresh/utils": "^1.2.0",
"@rslib/core": "^0.0.16",
"@rspack/core": "1.0.14",
"@rspack/test-tools": "1.0.14",
"@swc/plugin-prefresh": "^2.0.10",
"@swc/helpers": "0.5.13",
"@types/node": "^22.8.6",
"@swc/plugin-prefresh": "^2.0.10",
"@types/jest": "29.5.14",
"@types/node": "^22.8.6",
"cross-env": "^7.0.3",
"execa": "9.5.1",
"fs-extra": "11.2.0",
Expand Down
104 changes: 104 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from '@rslib/core';

export default defineConfig({
lib: [
{ format: 'esm', syntax: 'es2021', dts: true },
{ format: 'cjs', syntax: 'es2021' },
],
output: {
target: 'node',
},
});
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import fs from 'node:fs';
import { createRequire } from 'node:module';
import { dirname } from 'node:path';
import type {
Compiler,
RspackPluginInstance,
RuleSetCondition,
} from '@rspack/core';

const require = createRequire(import.meta.url);

export interface IPreactRefreshRspackPluginOptions {
/**
* Include files to be processed by the plugin.
Expand Down Expand Up @@ -133,5 +136,5 @@ class PreactRefreshRspackPlugin implements RspackPluginInstance {
}
}

// @ts-expect-error output module.exports
export = PreactRefreshRspackPlugin;
export { PreactRefreshRspackPlugin };
export default PreactRefreshRspackPlugin;
3 changes: 3 additions & 0 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
7 changes: 0 additions & 7 deletions tsconfig.build.json

This file was deleted.

21 changes: 8 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"baseUrl": "./",
"target": "ES2021",
"esModuleInterop": true,
"lib": ["ESNext"],
"module": "Node16",
"strict": true,
"declaration": true,
"isolatedModules": true,
"sourceMap": true,
"declarationMap": true,
"composite": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"checkJs": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"outDir": "dist",
"rootDir": "src"
"resolveJsonModule": true,
"moduleResolution": "Node16"
},
"include": ["src"]
}