MCPcopy
hub / github.com/esm-dev/esm.sh / Build

Method Build

server/build.go:135–199  ·  view source on GitHub ↗
(buildCtx context.Context)

Source from the content-addressed store, hash-verified

133}
134
135func (ctx *BuildContext) Build(buildCtx context.Context) (meta *BuildMeta, err error) {
136 if buildCtx == nil {
137 buildCtx = context.Background()
138 }
139 ctx.ctx = buildCtx
140 if err = ctx.checkCanceled(); err != nil {
141 return
142 }
143 if ctx.target == "types" {
144 return ctx.buildTypes()
145 }
146
147 // check previous build
148 meta, ok, err := ctx.Exists()
149 if err != nil || ok {
150 return
151 }
152 if err = ctx.checkCanceled(); err != nil {
153 return
154 }
155
156 // install the package
157 ctx.status = "install"
158 err = ctx.install()
159 if err != nil {
160 return
161 }
162
163 // check previous build again after installation (in case the sub-module path has been changed by the `install` function)
164 meta, ok, err = ctx.Exists()
165 if err != nil || ok {
166 return
167 }
168 if err = ctx.checkCanceled(); err != nil {
169 return
170 }
171
172 // analyze splitting modules if bundling
173 if ctx.pkgJson.Exports.Len() > 1 && ctx.shouldBundle() {
174 ctx.status = "analyze"
175 err = ctx.analyzeSplitting()
176 if err != nil {
177 return
178 }
179 }
180
181 // build the module
182 ctx.status = "build"
183 meta, _, err = ctx.buildModule(false)
184 if err != nil {
185 return
186 }
187 if err = ctx.checkCanceled(); err != nil {
188 return
189 }
190
191 // save the build result to the storage
192 key := ctx.Path()

Callers 7

runMethod · 0.80
buildUnenvNodeRuntimeFunction · 0.80
transformFunction · 0.80
treeShakeFunction · 0.80
buildLoaderFunction · 0.80
ServeCSSModuleMethod · 0.80
analyzeDependencyTreeMethod · 0.80

Calls 12

checkCanceledMethod · 0.95
buildTypesMethod · 0.95
ExistsMethod · 0.95
installMethod · 0.95
shouldBundleMethod · 0.95
analyzeSplittingMethod · 0.95
buildModuleMethod · 0.95
PathMethod · 0.95
encodeBuildMetaFunction · 0.85
ErrorMethod · 0.80
PutMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected