Skip to content

Commit 3feffbe

Browse files
authored
Enable main compilation by default for all @dataform/core versions >= 2.0.4. (#1401)
* Use main compilation by default for all @dataform/core versions >= 2.0.4. * use semver.subset
1 parent 4cb82ed commit 3feffbe

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

api/commands/compile.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from "fs";
22
import * as path from "path";
3+
import * as semver from "semver";
34

45
import { ChildProcess, fork } from "child_process";
56
import deepmerge from "deepmerge";
@@ -40,6 +41,18 @@ export async function compile(
4041
);
4142
}
4243

44+
if (compileConfig.useMain === null || compileConfig.useMain === undefined) {
45+
try {
46+
const packageJson = JSON.parse(
47+
fs.readFileSync(`${compileConfig.projectDir}/package.json`, "utf8")
48+
);
49+
const dataformCoreVersion = packageJson.dependencies["@dataform/core"];
50+
compileConfig.useMain = semver.subset(dataformCoreVersion, ">=2.0.4");
51+
} catch (e) {
52+
// Silently catch any thrown Error. Do not attempt to use `main` compilation.
53+
}
54+
}
55+
4356
const result = await CompileChildProcess.forkProcess().compile(compileConfig);
4457

4558
if (compileConfig.useMain) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@types/readline-sync": "^1.4.3",
4444
"@types/request": "^2.48.3",
4545
"@types/rimraf": "^2.0.2",
46-
"@types/semver": "^6.2.0",
46+
"@types/semver": "^7.3.13",
4747
"@types/ssh2": "^0.5.43",
4848
"@types/stack-trace": "^0.0.29",
4949
"@types/swagger-schema-official": "^2.0.20",
@@ -118,7 +118,7 @@
118118
"rimraf": "^2.6.2",
119119
"rollup": "^2.7.3",
120120
"rollup-plugin-dts": "^1.4.0",
121-
"semver": "^7.1.2",
121+
"semver": "^7.3.8",
122122
"snowflake-sdk": "^1.6.12",
123123
"source-map-loader": "^0.2.0",
124124
"sql-formatter": "^2.3.3",

version.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# NOTE: If you change the format of this line, you must change the bash command
22
# in /scripts/publish to extract the version string correctly.
3-
DF_VERSION = "2.0.3"
3+
DF_VERSION = "2.0.4"

yarn.lock

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,10 @@
11701170
"@types/glob" "*"
11711171
"@types/node" "*"
11721172

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

11781178
"@types/serve-static@*":
11791179
version "1.13.3"
@@ -9680,6 +9680,13 @@ semver@^7.3.2:
96809680
dependencies:
96819681
lru-cache "^6.0.0"
96829682

9683+
semver@^7.3.8:
9684+
version "7.3.8"
9685+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
9686+
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
9687+
dependencies:
9688+
lru-cache "^6.0.0"
9689+
96839690
send@0.17.1:
96849691
version "0.17.1"
96859692
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"

0 commit comments

Comments
 (0)