@rspack/core 0.0.3 → 0.0.7

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/example/basic.ts +29 -1
  3. package/{dist → lib}/bin/index.d.ts +0 -0
  4. package/{dist → lib}/bin/index.js +0 -0
  5. package/{dist → lib}/build.d.ts +0 -0
  6. package/{dist → lib}/build.js +0 -0
  7. package/lib/config/builtins.d.ts +3 -0
  8. package/lib/config/builtins.js +2 -0
  9. package/lib/config/context.d.ts +2 -0
  10. package/lib/config/context.js +2 -0
  11. package/lib/config/define.d.ts +2 -0
  12. package/lib/config/define.js +2 -0
  13. package/lib/config/dev.d.ts +17 -0
  14. package/lib/config/dev.js +17 -0
  15. package/lib/config/entry.d.ts +2 -0
  16. package/lib/config/entry.js +2 -0
  17. package/lib/config/external.d.ts +2 -0
  18. package/lib/config/external.js +2 -0
  19. package/lib/config/index.d.ts +45 -0
  20. package/lib/config/index.js +37 -0
  21. package/lib/config/mode.d.ts +2 -0
  22. package/lib/config/mode.js +2 -0
  23. package/{dist/index.d.ts → lib/config/module.d.ts} +41 -29
  24. package/lib/config/module.js +121 -0
  25. package/lib/config/output.d.ts +17 -0
  26. package/lib/config/output.js +14 -0
  27. package/lib/config/plugin.d.ts +5 -0
  28. package/lib/config/plugin.js +2 -0
  29. package/lib/config/resolve.d.ts +6 -0
  30. package/lib/config/resolve.js +2 -0
  31. package/lib/config/target.d.ts +5 -0
  32. package/lib/config/target.js +13 -0
  33. package/lib/index.d.ts +39 -0
  34. package/lib/index.js +154 -0
  35. package/{dist → lib}/server/index.d.ts +0 -0
  36. package/{dist → lib}/server/index.js +0 -0
  37. package/package.json +26 -11
  38. package/src/config/builtins.ts +5 -0
  39. package/src/config/context.ts +3 -0
  40. package/src/config/define.ts +3 -0
  41. package/src/config/dev.ts +32 -0
  42. package/src/config/entry.ts +3 -0
  43. package/src/config/external.ts +3 -0
  44. package/src/config/index.ts +80 -0
  45. package/src/config/mode.ts +2 -0
  46. package/src/config/module.ts +240 -0
  47. package/src/config/output.ts +29 -0
  48. package/src/config/plugin.ts +6 -0
  49. package/src/config/resolve.ts +6 -0
  50. package/src/config/target.ts +28 -0
  51. package/src/index.ts +107 -219
  52. package/tests/config.test.ts +40 -0
  53. package/tsconfig.json +6 -5
  54. package/dist/config.d.ts +0 -43
  55. package/dist/config.js +0 -25
  56. package/dist/index.js +0 -184
  57. package/src/config.ts +0 -66
package/src/config.ts DELETED
@@ -1,66 +0,0 @@
1
- import type { RawOptions } from "@rspack/binding";
2
-
3
- import type { ModuleRule } from ".";
4
- import { createRawModuleRuleUses } from ".";
5
-
6
- export type Plugin = {
7
- name: string;
8
- done?: () => void | Promise<void>;
9
- };
10
-
11
- export interface RspackOptions {
12
- /**
13
- * Entry points of compilation.
14
- */
15
- entry?: RawOptions["entry"];
16
- /**
17
- * An **absolute** path pointed the
18
- */
19
- context?: RawOptions["context"];
20
- /**
21
- * An array of plugins
22
- */
23
- plugins?: Plugin[];
24
- /**
25
- * dev server
26
- */
27
- dev?: {
28
- port?: Number;
29
- static?: {
30
- directory?: string;
31
- };
32
- };
33
- /**
34
- * Module configuration.
35
- */
36
- module?: {
37
- rules?: ModuleRule[];
38
- parser?: RawOptions["module"]["parser"];
39
- };
40
- define?: RawOptions["define"];
41
- target?: RawOptions["target"];
42
- mode?: RawOptions["mode"];
43
- external?: RawOptions["external"];
44
- }
45
-
46
- export function User2Native(config: RspackOptions): RawOptions & {
47
- plugins: Plugin[];
48
- } {
49
- return {
50
- entry: config.entry ?? {},
51
- context: config.context,
52
- define: config.define,
53
- target: config.target,
54
- external: config.external,
55
- plugins: config.plugins ?? [],
56
- module: {
57
- // TODO: support mutliple rules to support `Module Type`
58
- rules: (config?.module?.rules ?? []).map(rule => {
59
- return {
60
- ...rule,
61
- uses: createRawModuleRuleUses(rule.uses || [])
62
- };
63
- })
64
- }
65
- };
66
- }