diff options
author | 2021-12-15 15:16:53 -0800 | |
---|---|---|
committer | 2021-12-15 15:16:53 -0800 | |
commit | 62fb5ea9e396c5296f845d32f1aae5629fbf5836 (patch) | |
tree | b65c610b98ab6301a96b6180b064a89fcb49f4cc /src/import_record.zig | |
parent | a6ec858750a8a4c19b0bc94ecec00955f8b523c4 (diff) | |
download | bun-jarred/live-bindings.tar.gz bun-jarred/live-bindings.tar.zst bun-jarred/live-bindings.zip |
wip fix live bindingsjarred/live-bindings
Diffstat (limited to 'src/import_record.zig')
-rw-r--r-- | src/import_record.zig | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/import_record.zig b/src/import_record.zig index aa82e4731..4d4199004 100644 --- a/src/import_record.zig +++ b/src/import_record.zig @@ -44,61 +44,64 @@ pub const ImportRecord = struct { range: logger.Range, path: fs.Path, - // 0 is invalid + /// 0 is invalid module_id: u32 = 0, source_index: Ref.Int = std.math.maxInt(Ref.Int), print_mode: PrintMode = .normal, - // True for the following cases: - // - // try { require('x') } catch { handle } - // try { await import('x') } catch { handle } - // try { require.resolve('x') } catch { handle } - // import('x').catch(handle) - // import('x').then(_, handle) - // - // In these cases we shouldn't generate an error if the path could not be - // resolved. + /// True for the following cases: + /// + /// try { require('x') } catch { handle } + /// try { await import('x') } catch { handle } + /// try { require.resolve('x') } catch { handle } + /// import('x').catch(handle) + /// import('x').then(_, handle) + /// + /// In these cases we shouldn't generate an error if the path could not be + /// resolved. handles_import_errors: bool = false, is_internal: bool = false, - // This tells the printer that we should print as export var $moduleID = ... - // Instead of using the path. + /// This tells the printer that we should print as export var $moduleID = ... + /// Instead of using the path. is_bundled: bool = false, - // Sometimes the parser creates an import record and decides it isn't needed. - // For example, TypeScript code may have import statements that later turn - // out to be type-only imports after analyzing the whole file. + /// Sometimes the parser creates an import record and decides it isn't needed. + /// For example, TypeScript code may have import statements that later turn + /// out to be type-only imports after analyzing the whole file. is_unused: bool = false, - // If this is true, the import contains syntax like "* as ns". This is used - // to determine whether modules that have no exports need to be wrapped in a - // CommonJS wrapper or not. + /// If this is true, the import contains syntax like "* as ns". This is used + /// to determine whether modules that have no exports need to be wrapped in a + /// CommonJS wrapper or not. contains_import_star: bool = false, - // If this is true, the import contains an import for the alias "default", - // either via the "import x from" or "import {default as x} from" syntax. + /// If this is true, the import contains an import for the alias "default", + /// either via the "import x from" or "import {default as x} from" syntax. contains_default_alias: bool = false, - // If true, this "export * from 'path'" statement is evaluated at run-time by - // calling the "__reExport()" helper function + /// If true, this "export * from 'path'" statement is evaluated at run-time by + /// calling the "__reExport()" helper function calls_run_time_re_export_fn: bool = false, - // Tell the printer to wrap this call to "require()" in "__toModule(...)" + /// Tell the printer to wrap this call to "require()" in "__toModule(...)" wrap_with_to_module: bool = false, - // True for require calls like this: "try { require() } catch {}". In this - // case we shouldn't generate an error if the path could not be resolved. + /// True for require calls like this: "try { require() } catch {}". In this + /// case we shouldn't generate an error if the path could not be resolved. is_inside_try_body: bool = false, - // If true, this was originally written as a bare "import 'file'" statement + /// If true, this was originally written as a bare "import 'file'" statement was_originally_bare_import: bool = false, was_originally_require: bool = false, + /// If a macro used <import>, it will be tracked here. + was_injected_by_macro: bool = false, + kind: ImportKind, pub const PrintMode = enum { |