Skip to content

Commit

Permalink
MB-48738: add initial esbuild script
Browse files Browse the repository at this point in the history
Change-Id: I5bd90857f53ed6253d2608dd5e60ba5c76322530
Reviewed-on: http://review.couchbase.org/c/ns_server/+/163992
Well-Formed: Build Bot <build@couchbase.com>
Tested-by: Pavel Blagodov <stochmail@gmail.com>
Reviewed-by: Chris Hillery <ceej@couchbase.com>
  • Loading branch information
pavel-blagodov committed Nov 11, 2021
1 parent e9c2099 commit 620b300
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 224 deletions.
7 changes: 3 additions & 4 deletions deps/gocode/CMakeLists.txt
Expand Up @@ -18,10 +18,9 @@ GoInstall (TARGET ns_godu PACKAGE godu
GOVERSION 1.8.5
INSTALL_PATH bin/priv)

GoInstall (TARGET ns_minify PACKAGE minify
GOPATH "${CMAKE_CURRENT_SOURCE_DIR}" "${GODEPSDIR}"
GOVERSION 1.8.5
INSTALL_PATH bin/priv)
GoModBuild (TARGET ns_minify PACKAGE github.com/couchbase/ns_server/deps/gocode/src/minify
GOVERSION 1.13
OUTPUT minify)

GoInstall (TARGET ns_gosecrets PACKAGE gosecrets
GOPATH "${CMAKE_CURRENT_SOURCE_DIR}" "${GODEPSDIR}"
Expand Down
70 changes: 70 additions & 0 deletions deps/gocode/src/minify/main.go
@@ -0,0 +1,70 @@
// @author Couchbase <info@couchbase.com>
// @copyright 2016-Present Couchbase, Inc.
//
// Use of this software is governed by the Business Source License included
// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
// in that file, in accordance with the Business Source License, use of this
// software will be governed by the Apache License, Version 2.0, included in
// the file licenses/APL2.txt.
package main

import (
"flag"
"os"
"log"
"github.com/evanw/esbuild/pkg/api"
)

func main() {
inDir := flag.String("in-dir", "", "path to js source dir (required)")
outDir := flag.String("out-dir", "", "path to js output dir (required)")
flag.Parse()
log.SetFlags(0)

if *inDir == "" {
log.Printf("Error: path to js source dir must be specified\n")
flag.Usage()
os.Exit(1)
}

if *outDir == "" {
log.Printf("Error: path to js source dir must be specified\n")
flag.Usage()
os.Exit(1)
}

result := api.Build(api.BuildOptions{
// MinifyWhitespace: true,
// // MinifyIdentifiers: true,
// MinifySyntax: true,
KeepNames: true,

AbsWorkingDir: *inDir + "/app",
Outdir: *outDir,

NodePaths: []string{
*inDir + "/web_modules",
*inDir + "/libs",
*inDir + "/app",
},
EntryPoints: []string{
"main.js",
},
Bundle: true,
Splitting: true,
Write: true,
Metafile: true,
Format: api.FormatESModule,
LogLevel: api.LogLevelInfo,
Engines: []api.Engine{
{api.EngineChrome, "93"},
{api.EngineFirefox, "92"},
{api.EngineSafari, "14"},
{api.EngineEdge, "93"},
},
})

if len(result.Errors) > 0 {
os.Exit(1)
}
}
220 changes: 0 additions & 220 deletions deps/gocode/src/minify/minify.go

This file was deleted.

5 changes: 5 additions & 0 deletions go.mod
@@ -0,0 +1,5 @@
module github.com/couchbase/ns_server

go 1.17

require github.com/evanw/esbuild v0.12.27
12 changes: 12 additions & 0 deletions go.sum
@@ -0,0 +1,12 @@
github.com/evanw/esbuild v0.12.27 h1:pWtTIKGO4Af2P2u6Jps5vmJy1wpUqdx4QmI1Y/fvxY8=
github.com/evanw/esbuild v0.12.27/go.mod h1:GG+zjdi59yh3ehDn4ZWfPcATxjPDUH53iU4ZJbp7dkY=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365 h1:6wSTsvPddg9gc/mVEEyk9oOAoxn+bT4Z9q1zx+4RwA4=
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

0 comments on commit 620b300

Please sign in to comment.