@knighted/module 1.3.0 → 1.3.1

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 (46) hide show
  1. package/dist/ast.d.ts +1 -0
  2. package/dist/async.d.ts +4 -0
  3. package/dist/buildEsmPrelude.d.ts +14 -0
  4. package/dist/cjs/ast.d.cts +1 -0
  5. package/dist/cjs/async.d.cts +4 -0
  6. package/dist/cjs/buildEsmPrelude.d.cts +14 -0
  7. package/dist/cjs/exportBagToEsm.d.cts +13 -0
  8. package/dist/cjs/format.cjs +78 -852
  9. package/dist/cjs/formatVisitor.d.cts +42 -0
  10. package/dist/cjs/helpers/async.cjs +57 -0
  11. package/dist/cjs/idiomaticPlan.d.cts +28 -0
  12. package/dist/cjs/interopHelpers.d.cts +5 -0
  13. package/dist/cjs/lowerCjsRequireToImports.d.cts +17 -0
  14. package/dist/cjs/lowerEsmToCjs.d.cts +22 -0
  15. package/dist/cjs/pipeline/buildEsmPrelude.cjs +65 -0
  16. package/dist/cjs/pipeline/exportBagToEsm.cjs +81 -0
  17. package/dist/cjs/pipeline/formatVisitor.cjs +171 -0
  18. package/dist/cjs/pipeline/idiomaticPlan.cjs +224 -0
  19. package/dist/cjs/pipeline/interopHelpers.cjs +10 -0
  20. package/dist/cjs/pipeline/lowerCjsRequireToImports.cjs +110 -0
  21. package/dist/cjs/pipeline/lowerEsmToCjs.cjs +204 -0
  22. package/dist/exportBagToEsm.d.ts +13 -0
  23. package/dist/format.js +74 -848
  24. package/dist/formatVisitor.d.ts +42 -0
  25. package/dist/helpers/ast.d.ts +1 -0
  26. package/dist/helpers/async.d.ts +4 -0
  27. package/dist/helpers/async.js +50 -0
  28. package/dist/idiomaticPlan.d.ts +28 -0
  29. package/dist/interopHelpers.d.ts +5 -0
  30. package/dist/lowerCjsRequireToImports.d.ts +17 -0
  31. package/dist/lowerEsmToCjs.d.ts +22 -0
  32. package/dist/pipeline/buildEsmPrelude.d.ts +14 -0
  33. package/dist/pipeline/buildEsmPrelude.js +59 -0
  34. package/dist/pipeline/exportBagToEsm.d.ts +13 -0
  35. package/dist/pipeline/exportBagToEsm.js +75 -0
  36. package/dist/pipeline/formatVisitor.d.ts +42 -0
  37. package/dist/pipeline/formatVisitor.js +166 -0
  38. package/dist/pipeline/idiomaticPlan.d.ts +28 -0
  39. package/dist/pipeline/idiomaticPlan.js +218 -0
  40. package/dist/pipeline/interopHelpers.d.ts +5 -0
  41. package/dist/pipeline/interopHelpers.js +5 -0
  42. package/dist/pipeline/lowerCjsRequireToImports.d.ts +17 -0
  43. package/dist/pipeline/lowerCjsRequireToImports.js +102 -0
  44. package/dist/pipeline/lowerEsmToCjs.d.ts +22 -0
  45. package/dist/pipeline/lowerEsmToCjs.js +197 -0
  46. package/package.json +1 -1
package/dist/ast.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Node } from 'oxc-parser';
2
2
  import type { CjsExport } from '../types.js';
3
+ export type { Node };
3
4
  export type IdentifierNode = Extract<Node, {
4
5
  type: 'Identifier';
5
6
  }>;
@@ -0,0 +1,4 @@
1
+ import type { Node, ProgramNode } from './ast.js';
2
+ declare const hasTopLevelAwait: (program: ProgramNode) => boolean;
3
+ declare const isAsyncContext: (ancestors: Node[]) => boolean;
4
+ export { hasTopLevelAwait, isAsyncContext };
@@ -0,0 +1,14 @@
1
+ import type { FormatterOptions } from '../types.js';
2
+ type BuildEsmPreludeOptions = {
3
+ needsCreateRequire: boolean;
4
+ needsRequireResolveHelper: boolean;
5
+ requireMainNeedsRealpath: boolean;
6
+ hoistedImports: string[];
7
+ hoistedStatements: string[];
8
+ needsImportInterop: boolean;
9
+ importMetaPreludeMode: FormatterOptions['importMetaPrelude'];
10
+ importMetaRef: boolean;
11
+ useExportsBag: boolean;
12
+ };
13
+ declare const buildEsmPrelude: (options: BuildEsmPreludeOptions) => string;
14
+ export { buildEsmPrelude };
@@ -1,5 +1,6 @@
1
1
  import type { Node } from 'oxc-parser';
2
2
  import type { CjsExport } from '../types.cjs';
3
+ export type { Node };
3
4
  export type IdentifierNode = Extract<Node, {
4
5
  type: 'Identifier';
5
6
  }>;
@@ -0,0 +1,4 @@
1
+ import type { Node, ProgramNode } from './ast.cjs';
2
+ declare const hasTopLevelAwait: (program: ProgramNode) => boolean;
3
+ declare const isAsyncContext: (ancestors: Node[]) => boolean;
4
+ export { hasTopLevelAwait, isAsyncContext };
@@ -0,0 +1,14 @@
1
+ import type { FormatterOptions } from '../types.cjs';
2
+ type BuildEsmPreludeOptions = {
3
+ needsCreateRequire: boolean;
4
+ needsRequireResolveHelper: boolean;
5
+ requireMainNeedsRealpath: boolean;
6
+ hoistedImports: string[];
7
+ hoistedStatements: string[];
8
+ needsImportInterop: boolean;
9
+ importMetaPreludeMode: FormatterOptions['importMetaPrelude'];
10
+ importMetaRef: boolean;
11
+ useExportsBag: boolean;
12
+ };
13
+ declare const buildEsmPrelude: (options: BuildEsmPreludeOptions) => string;
14
+ export { buildEsmPrelude };
@@ -0,0 +1,13 @@
1
+ import MagicString from 'magic-string';
2
+ import type { ExportsMap } from '../helpers/ast.cjs';
3
+ type WarnOnce = (codeId: string, message: string, loc?: {
4
+ start: number;
5
+ end: number;
6
+ }) => void;
7
+ declare const exportBagToEsm: (params: {
8
+ code: MagicString;
9
+ exportTable: ExportsMap;
10
+ warnOnce: WarnOnce;
11
+ importMetaRef: boolean;
12
+ }) => boolean;
13
+ export { exportBagToEsm, type WarnOnce };