(
name: string,
config: ResolvedConfig,
context: DevEnvironmentContext,
)
| 110 | public bundledDev?: BundledDev |
| 111 | |
| 112 | constructor( |
| 113 | name: string, |
| 114 | config: ResolvedConfig, |
| 115 | context: DevEnvironmentContext, |
| 116 | ) { |
| 117 | let options = config.environments[name] |
| 118 | if (!options) { |
| 119 | throw new Error(`Environment "${name}" is not defined in the config.`) |
| 120 | } |
| 121 | if (context.options) { |
| 122 | options = mergeConfig( |
| 123 | options, |
| 124 | context.options, |
| 125 | ) as ResolvedEnvironmentOptions |
| 126 | } |
| 127 | super(name, config, options) |
| 128 | if ( |
| 129 | options.isBundled || |
| 130 | (name === 'client' && config.experimental.bundledDev) |
| 131 | ) { |
| 132 | context.disableDepsOptimizer = true |
| 133 | this.bundledDev = new BundledDev(this) |
| 134 | } |
| 135 | |
| 136 | this._pendingRequests = new Map() |
| 137 | |
| 138 | this.moduleGraph = new EnvironmentModuleGraph(name, (url: string) => |
| 139 | this.pluginContainer!.resolveId(url, undefined), |
| 140 | ) |
| 141 | |
| 142 | this._crawlEndFinder = setupOnCrawlEnd() |
| 143 | |
| 144 | this._remoteRunnerOptions = context.remoteRunner ?? {} |
| 145 | this._skipFsCheck = !!( |
| 146 | context.transport && |
| 147 | !(isWebSocketServer in context.transport) && |
| 148 | context.transport.skipFsCheck |
| 149 | ) |
| 150 | |
| 151 | this.hot = context.transport |
| 152 | ? isWebSocketServer in context.transport |
| 153 | ? context.transport |
| 154 | : normalizeHotChannel(context.transport, context.hot) |
| 155 | : normalizeHotChannel({}, context.hot) |
| 156 | |
| 157 | this.hot.setInvokeHandler({ |
| 158 | fetchModule: (id, importer, options) => { |
| 159 | if (context.disableFetchModule) { |
| 160 | throw new Error('fetchModule is disabled in this environment') |
| 161 | } |
| 162 | return this.fetchModule(id, importer, options) |
| 163 | }, |
| 164 | getBuiltins: async () => { |
| 165 | return this.config.resolve.builtins.map((builtin) => |
| 166 | typeof builtin === 'string' |
| 167 | ? { type: 'string', value: builtin } |
| 168 | : { type: 'RegExp', source: builtin.source, flags: builtin.flags }, |
| 169 | ) |
nothing calls this directly
no test coverage detected