| 2947 | } |
| 2948 | |
| 2949 | applyImportPhase( |
| 2950 | node: Undone<N.ImportDeclaration | N.ExportNamedDeclaration>, |
| 2951 | isExport: boolean, |
| 2952 | phase: string | null, |
| 2953 | loc?: number, |
| 2954 | ): void { |
| 2955 | if (isExport) { |
| 2956 | if (!process.env.IS_PUBLISH) { |
| 2957 | if (phase === "source") { |
| 2958 | throw new Error( |
| 2959 | `Assertion failure: export declarations do not support the '${phase}' phase.`, |
| 2960 | ); |
| 2961 | } |
| 2962 | } |
| 2963 | if (phase === "defer") { |
| 2964 | this.expectPlugin("deferredReexports", loc); |
| 2965 | (node as N.ExportNamedDeclaration).phase = "defer"; |
| 2966 | } |
| 2967 | return; |
| 2968 | } |
| 2969 | |
| 2970 | if (phase === "source") { |
| 2971 | this.expectPlugin("sourcePhaseImports", loc); |
| 2972 | (node as N.ImportDeclaration).phase = "source"; |
| 2973 | } else if (phase === "defer") { |
| 2974 | this.expectPlugin("deferredImportEvaluation", loc); |
| 2975 | (node as N.ImportDeclaration).phase = "defer"; |
| 2976 | } else if ( |
| 2977 | this.hasPlugin("sourcePhaseImports") || |
| 2978 | this.hasPlugin("deferredImportEvaluation") |
| 2979 | ) { |
| 2980 | (node as N.ImportDeclaration).phase = null; |
| 2981 | } |
| 2982 | } |
| 2983 | |
| 2984 | /* |
| 2985 | * Parse `source` in `import source x from "x"`, disambiguating |