Skip to content

Commit

Permalink
πŸ› Fix #7 defualt node platform
Browse files Browse the repository at this point in the history
πŸ”– v0.0.9
  • Loading branch information
CryogenicPlanet committed Nov 8, 2021
1 parent 2d25f56 commit a8941fa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ func createCliApp() cli.App {
Usage: "Will automatically deploy report to netlify",
Destination: &netlifyToken,
},
&cli.BoolFlag{
Name: "browser",
Usage: "Will use esbuild browser platform (by default it uses node platform)",
Value: false,
Destination: &globalConfig.BrowserPlatform,
},
}

loadConfigFromFile()
Expand Down
3 changes: 2 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func getExternals() []string {
defaultExternals := []string{"path", "fs", "crypto", "os", "http", "child_process", "querystring", "readline", "tls", "assert", "buffer", "url", "net", "buffer", "tty", "util", "stream", "events", "zlib", "https", "worker_threads", "module", "http2", "dns"}
defaultExternals := []string{}

cliExternals := externals.Value()

Expand All @@ -34,6 +34,7 @@ type ConfigJSON struct {
DevDependencies bool `json:"dev"`
Externals []string `json:"externals"`
IgnoredNamespaces []string `json:"ignore-namespaces"`
BrowserPlatform bool `json:"browser-platform"`
}

func setupConfig() {
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ func depcheck() {

setDeps(packageJsonPaths)

platform := api.PlatformNode

if globalConfig.BrowserPlatform {
platform = api.PlatformBrowser
}

result := api.Build(api.BuildOptions{
EntryPoints: sourcePaths,
// EntryPoints: []string{"test/monorepo/packages/package-b/src/App.tsx"},
Expand All @@ -363,6 +369,7 @@ func depcheck() {
Plugins: []api.Plugin{depcheckPlugin},
External: getExternals(),
Metafile: true,
Platform: platform,
})

if len(result.Errors) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "depp-installer",
"version": "0.0.8-ci-error-handling",
"version": "0.0.9",
"description": " A fast unused and duplicate dependency checker ",
"repository": {
"type": "git",
Expand Down

0 comments on commit a8941fa

Please sign in to comment.