diff --git a/jscomp/build_tests/duplicated_symlinked_packages/input.js b/jscomp/build_tests/duplicated_symlinked_packages/input.js index c46338825a..ad80c4849f 100644 --- a/jscomp/build_tests/duplicated_symlinked_packages/input.js +++ b/jscomp/build_tests/duplicated_symlinked_packages/input.js @@ -1,34 +1,33 @@ -// https://github.com/rescript-lang/rescript-compiler/pull/5703#issuecomment-1518507161 -// const fs = require('fs') -// const path = require('path') -// const child_process = require('child_process') -// const rescript_exe = require("../../../scripts/bin_path").rescript_exe +const fs = require('fs') +const path = require('path') +const child_process = require('child_process') +const rescript_exe = require("../../../scripts/bin_path").rescript_exe -// const expectedFilePath = path.join(__dirname, 'out.expected') +const expectedFilePath = path.join(__dirname, 'out.expected') -// const updateTests = process.argv[2] === 'update' +const updateTests = process.argv[2] === 'update' -// function postProcessErrorOutput (output) { -// output = output.trimRight() -// output = output.replace(new RegExp(__dirname, 'gi'), '.') -// return output -// } -// child_process.execSync(`${rescript_exe} clean -with-deps`,{cwd:__dirname}) -// child_process.exec(rescript_exe, {cwd: __dirname}, (err, stdout, stderr) => { -// const actualErrorOutput = postProcessErrorOutput(stderr.toString()) -// if (updateTests) { -// fs.writeFileSync(expectedFilePath, actualErrorOutput) -// } else { -// const expectedErrorOutput = postProcessErrorOutput(fs.readFileSync(expectedFilePath, {encoding: 'utf-8'})) -// if (expectedErrorOutput !== actualErrorOutput) { -// console.error(`The old and new error output aren't the same`) -// console.error('\n=== Old:') -// console.error(expectedErrorOutput) -// console.error('\n=== New:') -// console.error(actualErrorOutput) -// process.exit(1) -// } -// } -// }) +function postProcessErrorOutput (output) { + output = output.trimRight() + output = output.replace(new RegExp(__dirname, 'gi'), '.') + return output +} +child_process.execSync(`${rescript_exe} clean -with-deps`,{cwd:__dirname}) +child_process.exec(rescript_exe, {cwd: __dirname}, (err, stdout, stderr) => { + const actualErrorOutput = postProcessErrorOutput(stderr.toString()) + if (updateTests) { + fs.writeFileSync(expectedFilePath, actualErrorOutput) + } else { + const expectedErrorOutput = postProcessErrorOutput(fs.readFileSync(expectedFilePath, {encoding: 'utf-8'})) + if (expectedErrorOutput !== actualErrorOutput) { + console.error(`The old and new error output aren't the same`) + console.error('\n=== Old:') + console.error(expectedErrorOutput) + console.error('\n=== New:') + console.error(actualErrorOutput) + process.exit(1) + } + } +}) diff --git a/jscomp/build_tests/transitive_pinned_dependency1/input.js b/jscomp/build_tests/transitive_pinned_dependency1/input.js index 6c3d790704..841f52ddcf 100644 --- a/jscomp/build_tests/transitive_pinned_dependency1/input.js +++ b/jscomp/build_tests/transitive_pinned_dependency1/input.js @@ -1,10 +1,9 @@ -// https://github.com/rescript-lang/rescript-compiler/pull/5703#issuecomment-1518507161 -// //@ts-check -// var child_process = require("child_process"); -// var assert = require("assert"); -// var fs = require("fs") -// var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +//@ts-check +var child_process = require("child_process"); +var assert = require("assert"); +var fs = require("fs") +var rescript_exe = require("../../../scripts/bin_path").rescript_exe; -// console.log(child_process.execSync(rescript_exe, { encoding: "utf8", cwd: "./a" })); +console.log(child_process.execSync(rescript_exe, { encoding: "utf8", cwd: "./a" })); -// assert(fs.existsSync("./node_modules/c/lib/js/tests/test.mjs"), "dev files of module 'c' were not built by 'a' even though 'c' is a transitive pinned dependency of 'a' through 'b'") +assert(fs.existsSync("./node_modules/c/lib/js/tests/test.mjs"), "dev files of module 'c' were not built by 'a' even though 'c' is a transitive pinned dependency of 'a' through 'b'") diff --git a/jscomp/build_tests/transitive_pinned_dependency2/input.js b/jscomp/build_tests/transitive_pinned_dependency2/input.js index 6ec7c8a5c3..2ed725e214 100644 --- a/jscomp/build_tests/transitive_pinned_dependency2/input.js +++ b/jscomp/build_tests/transitive_pinned_dependency2/input.js @@ -1,10 +1,9 @@ -// https://github.com/rescript-lang/rescript-compiler/pull/5703#issuecomment-1518507161 -// //@ts-check -// var child_process = require("child_process"); -// var assert = require("assert"); -// var fs = require("fs") -// var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +//@ts-check +var child_process = require("child_process"); +var assert = require("assert"); +var fs = require("fs") +var rescript_exe = require("../../../scripts/bin_path").rescript_exe; -// console.log(child_process.execSync(rescript_exe, { encoding: "utf8", cwd: "./a" })); +console.log(child_process.execSync(rescript_exe, { encoding: "utf8", cwd: "./a" })); -// assert(!fs.existsSync("./node_modules/c/lib/js/tests/test.mjs"), "dev files of module 'c' were built by 'a' even though 'c' is not a pinned dependency of 'a'") +assert(!fs.existsSync("./node_modules/c/lib/js/tests/test.mjs"), "dev files of module 'c' were built by 'a' even though 'c' is not a pinned dependency of 'a'") diff --git a/jscomp/core/js_implementation.ml b/jscomp/core/js_implementation.ml index fc36725f0c..cc08a0cbd3 100644 --- a/jscomp/core/js_implementation.ml +++ b/jscomp/core/js_implementation.ml @@ -164,9 +164,9 @@ let after_parsing_impl ppf outputprefix (ast : Parsetree.structure) = let lambda, exports = Translmod.transl_implementation modulename typedtree_coercion in - let js_program ~module_system = + let js_program = print_if_pipe ppf Clflags.dump_rawlambda Printlambda.lambda lambda - |> Lam_compile_main.compile outputprefix module_system exports + |> Lam_compile_main.compile outputprefix NodeJS exports in if not !Js_config.cmj_only then Lam_compile_main.lambda_as_module js_program outputprefix); diff --git a/jscomp/core/lam_compile_main.ml b/jscomp/core/lam_compile_main.ml index 14efd1e77a..b519006447 100644 --- a/jscomp/core/lam_compile_main.ml +++ b/jscomp/core/lam_compile_main.ml @@ -288,18 +288,18 @@ js let (//) = Filename.concat let lambda_as_module - (lambda_output : module_system: Js_packages_info.module_system -> J.deps_program) + (lambda_output : J.deps_program) (output_prefix : string) : unit = let package_info = Js_packages_state.get_packages_info () in if Js_packages_info.is_empty package_info && !Js_config.js_stdout then begin - Js_dump_program.dump_deps_program ~output_prefix NodeJS (lambda_output ~module_system: NodeJS) stdout + Js_dump_program.dump_deps_program ~output_prefix NodeJS (lambda_output) stdout end else Js_packages_info.iter package_info (fun {module_system; path; suffix} -> let output_chan chan = Js_dump_program.dump_deps_program ~output_prefix module_system - (lambda_output ~module_system) + (lambda_output) chan in let basename = Ext_namespace.change_ext_ns_suffix diff --git a/jscomp/core/lam_compile_main.mli b/jscomp/core/lam_compile_main.mli index c1cb299307..ee35f02cb8 100644 --- a/jscomp/core/lam_compile_main.mli +++ b/jscomp/core/lam_compile_main.mli @@ -32,4 +32,4 @@ val compile : string -> Js_packages_info.module_system -> Ident.t list -> Lambda {!Env.get_unit_name ()} *) -val lambda_as_module : (module_system: Js_packages_info.module_system -> J.deps_program) -> string -> unit +val lambda_as_module : J.deps_program -> string -> unit diff --git a/jscomp/test/Import.js b/jscomp/test/Import.js index ab767b4f3d..e559af2e98 100644 --- a/jscomp/test/Import.js +++ b/jscomp/test/Import.js @@ -1,3 +1,4 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; var Curry = require("../../lib/js/curry.js");