@rslib/core 0.1.4 → 0.1.5

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.
@@ -1,11 +1,5 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/web-infra-dev/rspack/blob/0a89e433a9f8596a7c6c4326542f168b5982d2da/packages/rspack/src/builtin-plugin/css-extract/loader.ts
5
- * 1. remove hmr/webpack runtime
6
- * 2. add `this.emitFile` to emit css files
7
- * 3. add `import './[name].css';`
8
- */ const PLUGIN_NAME = 'LIB_CSS_EXTRACT_LOADER';
2
+ const PLUGIN_NAME = 'LIB_CSS_EXTRACT_LOADER';
9
3
  function stringifyLocal(value) {
10
4
  return 'function' == typeof value ? value.toString() : JSON.stringify(value);
11
5
  }
@@ -30,7 +24,6 @@ const pitch = function(request, _, _data) {
30
24
  const esModule = void 0 === options.esModule || options.esModule;
31
25
  let dependencies = [];
32
26
  try {
33
- // eslint-disable-next-line no-underscore-dangle
34
27
  const exports = originalExports.__esModule ? originalExports.default : originalExports;
35
28
  namedExport = originalExports.__esModule && (!originalExports.default || !('locals' in originalExports.default));
36
29
  if (namedExport) {
@@ -121,5 +114,5 @@ const pitch = function(request, _, _data) {
121
114
  handleExports(exports);
122
115
  });
123
116
  };
124
- /* ESM default export */ const libCssExtractLoader_rslib_entry_ = libCssExtractLoader_rslib_entry_loader;
117
+ const libCssExtractLoader_rslib_entry_ = libCssExtractLoader_rslib_entry_loader;
125
118
  export { libCssExtractLoader_rslib_entry_ as default, pitch };
@@ -0,0 +1,3 @@
1
+ import type { RsbuildConfig } from '@rsbuild/core';
2
+ import type { Format } from '../types';
3
+ export declare const composeAssetConfig: (bundle: boolean, format: Format) => RsbuildConfig;
@@ -11,7 +11,7 @@ export declare function parsePathQueryFragment(str: string): {
11
11
  };
12
12
  export declare function isCssModulesFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
13
13
  export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
14
- type ExternalCallback = (arg0?: null, arg1?: string) => void;
14
+ type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
15
15
  export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, isStyleRedirect: boolean): void | false;
16
16
  export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) => RsbuildConfig;
17
17
  export {};
@@ -0,0 +1 @@
1
+ {"//":"This file is for making TypeScript work with moduleResolution node16+.","version":"1.0.0"}
@@ -1,5 +1,6 @@
1
- import type { RsbuildConfig } from '@rsbuild/core';
1
+ import type { RsbuildConfig, Rspack } from '@rsbuild/core';
2
2
  import type { PluginDtsOptions } from 'rsbuild-plugin-dts';
3
+ import type { GetAsyncFunctionFromUnion } from './utils';
3
4
  export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
4
5
  export type FixedEcmaVersions = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023';
5
6
  export type LatestEcmaVersions = 'es2024' | 'esnext';
@@ -11,6 +12,7 @@ export type RsbuildConfigWithLibInfo = {
11
12
  };
12
13
  export type RsbuildConfigEntry = NonNullable<NonNullable<RsbuildConfig['source']>['entry']>;
13
14
  export type RsbuildConfigEntryItem = RsbuildConfigEntry[string];
15
+ export type RspackResolver = GetAsyncFunctionFromUnion<ReturnType<NonNullable<Rspack.ExternalItemFunctionData['getResolve']>>>;
14
16
  export type RsbuildConfigOutputTarget = NonNullable<RsbuildConfig['output']>['target'];
15
17
  export type Syntax = EcmaScriptVersion | string[];
16
18
  export type Dts = (Pick<PluginDtsOptions, 'bundle' | 'distPath' | 'abortOnError' | 'build'> & {
@@ -37,7 +39,22 @@ export type Shims = {
37
39
  require?: boolean;
38
40
  };
39
41
  };
42
+ export type JsRedirect = {
43
+ /**
44
+ * Whether to automatically redirect the import paths of JavaScript output files.
45
+ * @defaultValue `true`
46
+ */
47
+ path?: boolean;
48
+ /**
49
+ * Whether to automatically add the file extension to import paths based on the JavaScript output files.
50
+ * @defaultValue `true`
51
+ */
52
+ extension?: boolean;
53
+ };
40
54
  export type Redirect = {
55
+ /** Controls the redirect of the import paths of output JavaScript files. */
56
+ js?: JsRedirect;
57
+ /** Whether to redirect the import path of the style file. */
41
58
  style?: boolean;
42
59
  };
43
60
  export interface LibConfig extends RsbuildConfig {
@@ -10,3 +10,4 @@ export type DeepRequired<T> = Required<{
10
10
  [K in keyof T]: T[K] extends Required<T[K]> ? T[K] : DeepRequired<T[K]>;
11
11
  }>;
12
12
  export type ExcludesFalse = <T>(x: T | false | undefined | null) => x is T;
13
+ export type GetAsyncFunctionFromUnion<T> = T extends (...args: any[]) => Promise<any> ? T : never;
@@ -22,3 +22,4 @@ export declare function debounce<T extends (...args: any[]) => void>(func: T, wa
22
22
  export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
23
23
  export declare const isIntermediateOutputFormat: (format: Format) => boolean;
24
24
  export { color };
25
+ export declare function normalizeSlash(p: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://lib.rsbuild.dev",
6
6
  "bugs": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/web-infra-dev/rslib",
11
+ "url": "git+https://github.com/web-infra-dev/rslib.git",
12
12
  "directory": "packages/core"
13
13
  },
14
14
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@rsbuild/core": "~1.1.10",
36
36
  "tinyglobby": "^0.2.10",
37
- "rsbuild-plugin-dts": "0.1.4"
37
+ "rsbuild-plugin-dts": "0.1.5"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/fs-extra": "^11.0.4",
@@ -44,7 +44,8 @@
44
44
  "memfs": "^4.15.0",
45
45
  "picocolors": "1.1.1",
46
46
  "prebundle": "1.2.5",
47
- "rslib": "npm:@rslib/core@0.1.3",
47
+ "rsbuild-plugin-publint": "^0.2.1",
48
+ "rslib": "npm:@rslib/core@0.1.4",
48
49
  "rslog": "^1.2.3",
49
50
  "tsconfck": "3.1.4",
50
51
  "typescript": "^5.6.3",