Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pxt] Fix deprecation of "out" option in tsconfigs #9492

Merged
merged 1 commit into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backendutils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"declaration": true,
"out": "../built/backendutils.js",
"outFile": "../built/backendutils.js",
"newLine": "LF",
"sourceMap": false,
"moduleResolution": "node",
Expand Down
18 changes: 9 additions & 9 deletions cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1495,16 +1495,16 @@ function buildFolderAsync(p: string, optional?: boolean, outputName?: string): P

const tsConfig = JSON.parse(fs.readFileSync(path.join(p, "tsconfig.json"), "utf8"));
let isNodeModule = false;
if (outputName && tsConfig.compilerOptions.out !== `../built/${outputName}.js`) {
if (outputName && tsConfig.compilerOptions.outFile !== `../built/${outputName}.js`) {
// Special case to support target sim as an NPM package
if (/^node_modules[\/\\]+pxt-.*?-sim$/.test(p)) {
// Allow the out dir be inside the folder being built, and manually copy the result to ./built afterwards
if (tsConfig.compilerOptions.out !== `./built/${outputName}.js`) {
U.userError(`${p}/tsconfig.json expected compilerOptions.out:"./built/${outputName}.js", got "${tsConfig.compilerOptions.out}"`);
if (tsConfig.compilerOptions.outFile !== `./built/${outputName}.js`) {
U.userError(`${p}/tsconfig.json expected compilerOptions.outFile:"./built/${outputName}.js", got "${tsConfig.compilerOptions.outFile}"`);
}
isNodeModule = true;
} else {
U.userError(`${p}/tsconfig.json expected compilerOptions.out:"../built/${outputName}.js", got "${tsConfig.compilerOptions.out}"`);
U.userError(`${p}/tsconfig.json expected compilerOptions.outFile:"../built/${outputName}.js", got "${tsConfig.compilerOptions.outFile}"`);
}
}

Expand All @@ -1521,17 +1521,17 @@ function buildFolderAsync(p: string, optional?: boolean, outputName?: string): P
}).then(() => {
if (tsConfig.prepend) {
let files: string[] = tsConfig.prepend
files.push(tsConfig.compilerOptions.out)
files.push(tsConfig.compilerOptions.outFile)
let s = ""
for (let f of files) {
s += fs.readFileSync(path.resolve(p, f), "utf8") + "\n"
}
fs.writeFileSync(path.resolve(p, tsConfig.compilerOptions.out), s)
fs.writeFileSync(path.resolve(p, tsConfig.compilerOptions.outFile), s)
}

if (isNodeModule) {
const content = fs.readFileSync(path.resolve(p, tsConfig.compilerOptions.out), "utf8");
fs.writeFileSync(path.resolve("built", path.basename(tsConfig.compilerOptions.out)), content);
const content = fs.readFileSync(path.resolve(p, tsConfig.compilerOptions.outFile), "utf8");
fs.writeFileSync(path.resolve("built", path.basename(tsConfig.compilerOptions.outFile)), content);
}
})
}
Expand All @@ -1553,7 +1553,7 @@ function buildFolderAndBrowserifyAsync(p: string, optional?: boolean, outputName

const tsConfig = JSON.parse(fs.readFileSync(path.join(p, "tsconfig.json"), "utf8"));
if (outputName && tsConfig.compilerOptions.outDir !== `../built/${outputName}`) {
U.userError(`${p}/tsconfig.json expected compilerOptions.ourDir:"../built/${outputName}", got "${tsConfig.compilerOptions.outDir}"`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this just an old typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. very old typo :)

U.userError(`${p}/tsconfig.json expected compilerOptions.outDir:"../built/${outputName}", got "${tsConfig.compilerOptions.outDir}"`);
}

if (!fs.existsSync("node_modules/typescript")) {
Expand Down
2 changes: 1 addition & 1 deletion docfiles/pxtweb/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"declaration": true,
"out": "../../built/web/pxtweb.js",
"outFile": "../../built/web/pxtweb.js",
"newLine": "LF",
"sourceMap": false,
"lib": ["dom", "dom.iterable", "scripthost", "es2018"],
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function compileTsProject(dirname, destination, useOutdir, filename) {
let opts = useOutdir ? {
outDir: path.resolve(destination)
} : {
out: path.resolve(destination, path.basename(filename || dirname) + ".js")
outFile: path.resolve(destination, path.basename(filename || dirname) + ".js")
};

let configPath = path.join(dirname, "tsconfig.json");
Expand Down
2 changes: 1 addition & 1 deletion pxtblocks/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"declaration": true,
"out": "../built/pxtblocks.js",
"outFile": "../built/pxtblocks.js",
"newLine": "LF",
"sourceMap": false,
"moduleResolution": "node",
Expand Down
2 changes: 1 addition & 1 deletion pxtcompiler/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"noImplicitReturns": true,
"noImplicitThis": true,
"declaration": true,
"out": "../built/pxtcompiler.js",
"outFile": "../built/pxtcompiler.js",
"newLine": "LF",
"sourceMap": false,
"lib": [
Expand Down
2 changes: 1 addition & 1 deletion pxteditor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"declaration": true,
"out": "../built/pxteditor.js",
"outFile": "../built/pxteditor.js",
"newLine": "LF",
"sourceMap": false,
"moduleResolution": "node",
Expand Down
2 changes: 1 addition & 1 deletion pxtlib/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"noImplicitReturns": true,
"noImplicitThis": true,
"declaration": true,
"out": "../built/pxtlib.js",
"outFile": "../built/pxtlib.js",
"newLine": "LF",
"sourceMap": false,
"lib": [
Expand Down
2 changes: 1 addition & 1 deletion pxtpy/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"noImplicitThis": true,
"strictNullChecks": true,
"declaration": true,
"out": "../built/pxtpy.js",
"outFile": "../built/pxtpy.js",
"newLine": "LF",
"sourceMap": false,
"lib": [
Expand Down
2 changes: 1 addition & 1 deletion pxtrunner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"declaration": true,
"out": "../built/pxtrunner.js",
"outFile": "../built/pxtrunner.js",
"newLine": "LF",
"sourceMap": false,
"lib": [
Expand Down
2 changes: 1 addition & 1 deletion pxtsim/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"noImplicitReturns": true,
"noImplicitThis": true,
"declaration": true,
"out": "../built/pxtsim.js",
"outFile": "../built/pxtsim.js",
"newLine": "LF",
"sourceMap": false,
"moduleResolution": "node",
Expand Down
2 changes: 1 addition & 1 deletion tests/blocklycompiler-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"declaration": true,
"out": "../../built/tests/tests.spec.js",
"outFile": "../../built/tests/tests.spec.js",
"newLine": "LF",
"types": [
"chai",
Expand Down
2 changes: 1 addition & 1 deletion tests/blocks-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"declaration": true,
"out": "../../built/tests/blocksrunner.js",
"outFile": "../../built/tests/blocksrunner.js",
"newLine": "LF",
"lib": [
"dom",
Expand Down