Skip to content

Commit

Permalink
Enable main compilation by default for all @dataform/core versions …
Browse files Browse the repository at this point in the history
…>= `2.0.4`. (#1401)

* Use main compilation by default for all @dataform/core versions >= 2.0.4.

* use semver.subset
  • Loading branch information
BenBirt authored Nov 24, 2022
1 parent 4cb82ed commit 3feffbe
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
13 changes: 13 additions & 0 deletions api/commands/compile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as fs from "fs";
import * as path from "path";
import * as semver from "semver";

import { ChildProcess, fork } from "child_process";
import deepmerge from "deepmerge";
Expand Down Expand Up @@ -40,6 +41,18 @@ export async function compile(
);
}

if (compileConfig.useMain === null || compileConfig.useMain === undefined) {
try {
const packageJson = JSON.parse(
fs.readFileSync(`${compileConfig.projectDir}/package.json`, "utf8")
);
const dataformCoreVersion = packageJson.dependencies["@dataform/core"];
compileConfig.useMain = semver.subset(dataformCoreVersion, ">=2.0.4");
} catch (e) {
// Silently catch any thrown Error. Do not attempt to use `main` compilation.
}
}

const result = await CompileChildProcess.forkProcess().compile(compileConfig);

if (compileConfig.useMain) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@types/readline-sync": "^1.4.3",
"@types/request": "^2.48.3",
"@types/rimraf": "^2.0.2",
"@types/semver": "^6.2.0",
"@types/semver": "^7.3.13",
"@types/ssh2": "^0.5.43",
"@types/stack-trace": "^0.0.29",
"@types/swagger-schema-official": "^2.0.20",
Expand Down Expand Up @@ -118,7 +118,7 @@
"rimraf": "^2.6.2",
"rollup": "^2.7.3",
"rollup-plugin-dts": "^1.4.0",
"semver": "^7.1.2",
"semver": "^7.3.8",
"snowflake-sdk": "^1.6.12",
"source-map-loader": "^0.2.0",
"sql-formatter": "^2.3.3",
Expand Down
2 changes: 1 addition & 1 deletion version.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# NOTE: If you change the format of this line, you must change the bash command
# in /scripts/publish to extract the version string correctly.
DF_VERSION = "2.0.3"
DF_VERSION = "2.0.4"
15 changes: 11 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1170,10 +1170,10 @@
"@types/glob" "*"
"@types/node" "*"

"@types/semver@^6.2.0":
version "6.2.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.0.tgz#d688d574400d96c5b0114968705366f431831e1a"
integrity "sha1-1ojVdEANlsWwEUlocFNm9DGDHho= sha512-1OzrNb4RuAzIT7wHSsgZRlMBlNsJl+do6UblR7JMW4oB7bbR+uBEYtUh7gEc/jM84GGilh68lSOokyM/zNUlBA=="
"@types/semver@^7.3.13":
version "7.3.13"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91"
integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==

"@types/serve-static@*":
version "1.13.3"
Expand Down Expand Up @@ -9680,6 +9680,13 @@ semver@^7.3.2:
dependencies:
lru-cache "^6.0.0"

semver@^7.3.8:
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
dependencies:
lru-cache "^6.0.0"

[email protected]:
version "0.17.1"
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"
Expand Down

0 comments on commit 3feffbe

Please sign in to comment.