@@ -15,7 +15,7 @@ export interface ImportCheckDiagnostic {
1515/** A check whether or not an import is valid or not for an environment */
1616export type ImportCheck = (
1717 id : string ,
18- env : "ssr" | "client" ,
18+ env : string ,
1919) => ImportCheckDiagnostic | void ;
2020
2121export interface CheckImportOptions {
@@ -26,7 +26,7 @@ export function checkImports(pluginOptions: CheckImportOptions): Plugin {
2626 function check (
2727 options : CheckImportOptions ,
2828 id : string ,
29- env : "ssr " | "client" ,
29+ env : "server " | "client" ,
3030 ) : ImportCheckDiagnostic | undefined {
3131 for ( let i = 0 ; i < options . checks . length ; i ++ ) {
3232 const check = options . checks [ i ] ;
@@ -61,32 +61,36 @@ export function checkImports(pluginOptions: CheckImportOptions): Plugin {
6161 / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ,
6262 ] ,
6363 } ,
64- async handler ( id , importer , options ) {
64+ async handler ( id , importer ) {
6565 if (
6666 importer &&
6767 ( importer . startsWith ( "\0" ) || importer . includes ( "node_modules" ) ||
6868 importer . includes ( "deno::" ) )
6969 ) {
7070 return ;
7171 }
72- const env = options . ssr ? "ssr" : "client" ;
7372
7473 let result : ImportCheckDiagnostic | undefined ;
7574 if ( id . startsWith ( "." ) ) {
76- const resolved = await this . resolve ( id , importer , options ) ;
75+ const resolved = await this . resolve ( id , importer ) ;
7776
7877 if ( resolved !== null ) {
79- const key = `${ env } ::${ resolved . id } ::${ importer } ` ;
78+ const key =
79+ `${ this . environment . config . consumer } ::${ resolved . id } ::${ importer } ` ;
8080 if ( ! seen . has ( key ) ) {
81- result = check ( pluginOptions , resolved . id , env ) ;
81+ result = check (
82+ pluginOptions ,
83+ resolved . id ,
84+ this . environment . config . consumer ,
85+ ) ;
8286 }
8387
8488 seen . add ( key ) ;
8589 }
8690 } else {
87- const key = `${ env } ::${ id } ::${ importer } ` ;
91+ const key = `${ this . environment . config . consumer } ::${ id } ::${ importer } ` ;
8892 if ( ! seen . has ( key ) ) {
89- result = check ( pluginOptions , id , env ) ;
93+ result = check ( pluginOptions , id , this . environment . config . consumer ) ;
9094 }
9195 seen . add ( key ) ;
9296 }
0 commit comments