Skip to content

Commit

Permalink
Update dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
DZakh committed Aug 3, 2024
1 parent f43ef80 commit 2d71949
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 83 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"devDependencies": {
"@dzakh/rescript-ava": "2.3.0",
"@rescript/core": "^1.3.0",
"@rescript/core": "1.5.2",
"ava": "5.2.0",
"benchmark": "2.1.4",
"c8": "7.12.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/prepack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"lint:stdlib": "rescript-stdlib-vendorer lint"
},
"dependencies": {
"@rescript/core": "1.3.0",
"@rescript/core": "1.5.2",
"@rollup/plugin-replace": "5.0.2",
"execa": "7.1.1",
"rescript": "11.1.0",
"rescript": "12.0.0-alpha.1",
"rescript-nodejs": "16.1.0",
"rescript-stdlib-vendorer": "1.1.0",
"rollup": "3.21.0"
Expand Down
127 changes: 60 additions & 67 deletions packages/prepack/src/Prepack.bs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ import * as Core__List from "@rescript/core/src/Core__List.bs.mjs";
import * as Core__Option from "@rescript/core/src/Core__Option.bs.mjs";
import PluginReplace from "@rollup/plugin-replace";

var projectPath = ".";
let projectPath = ".";

var artifactsPath = Nodepath.join(projectPath, "packages/artifacts");
let artifactsPath = Nodepath.join(projectPath, "packages/artifacts");

var sourePaths = [
let sourePaths = [
"package.json",
"node_modules",
"src",
"rescript.json",
"README.md",
"RescriptSchema.gen.d.ts",
"RescriptSchema.gen.d.ts"
];

var jsInputPath = Nodepath.join(artifactsPath, "src/S.js");
let jsInputPath = Nodepath.join(artifactsPath, "src/S.js");

function update(json, path, value) {
var dict = Core__JSON.Decode.object(json);
var dict$1 = dict !== undefined ? Object.assign({}, dict) : {};
let dict = Core__JSON.Decode.object(json);
let dict$1 = dict !== undefined ? Object.assign({}, dict) : ({});
if (!path) {
return value;
}
var path$1 = path.tl;
var key = path.hd;
let path$1 = path.tl;
let key = path.hd;
if (path$1) {
dict$1[key] = update(Core__Option.getOr(dict$1[key], {}), path$1, value);
return dict$1;
Expand All @@ -45,115 +45,108 @@ function update(json, path, value) {
if (Nodefs.existsSync(artifactsPath)) {
Fs.rmSync(artifactsPath, {
recursive: true,
force: true,
force: true
});
}

Nodefs.mkdirSync(artifactsPath);

sourePaths.forEach(function (path) {
Fs.cpSync(
Nodepath.join(projectPath, path),
Nodepath.join(artifactsPath, path),
{
recursive: true,
}
);
Fs.cpSync(Nodepath.join(projectPath, path), Nodepath.join(artifactsPath, path), {
recursive: true
});
});

function updateJsonFile(src, path, value) {
var packageJsonData = Nodefs.readFileSync(src, {
encoding: "utf8",
let packageJsonData = Nodefs.readFileSync(src, {
encoding: "utf8"
});
var packageJson = JSON.parse(packageJsonData.toString());
var updatedPackageJson = JSON.stringify(
update(packageJson, Core__List.fromArray(path), value),
undefined,
2
);
let packageJson = JSON.parse(packageJsonData.toString());
let updatedPackageJson = JSON.stringify(update(packageJson, Core__List.fromArray(path), value), undefined, 2);
Nodefs.writeFileSync(src, Buffer.from(updatedPackageJson), {
encoding: "utf8",
encoding: "utf8"
});
}

Execa.execaSync("npm", ["run", "res:build"], {
cwd: artifactsPath,
Execa.execaSync("npm", [
"run",
"res:build"
], {
cwd: artifactsPath
});

var bundle = await Rollup.rollup({
let bundle = await Rollup.rollup({
input: jsInputPath,
external: [/S_Core\.bs\.mjs/],
external: [/S_Core\.bs\.mjs/]
});

var output = [
let output = [
{
file: Nodepath.join(artifactsPath, "dist/S.js"),
format: "cjs",
exports: "named",
plugins: [
PluginReplace({
plugins: [PluginReplace({
values: Object.fromEntries([
["S_Core.bs.mjs", "../src/S_Core.bs.js"],
["rescript/lib/es6", "rescript/lib/js"],
]),
}),
],
[
"S_Core.bs.mjs",
"../src/S_Core.bs.js"
],
[
"rescript/lib/es6",
"rescript/lib/js"
]
])
})]
},
{
file: Nodepath.join(artifactsPath, "dist/S.mjs"),
format: "es",
exports: "named",
plugins: [
PluginReplace({
values: Object.fromEntries([["S_Core.bs.mjs", "../src/S_Core.bs.mjs"]]),
}),
],
},
plugins: [PluginReplace({
values: Object.fromEntries([[
"S_Core.bs.mjs",
"../src/S_Core.bs.mjs"
]])
})]
}
];

for (var idx = 0, idx_finish = output.length; idx < idx_finish; ++idx) {
var outpuOptions = output[idx];
for(let idx = 0 ,idx_finish = output.length; idx < idx_finish; ++idx){
let outpuOptions = output[idx];
await bundle.write(outpuOptions);
}

await bundle.close();

Fs.rmSync(Nodepath.join(artifactsPath, "lib"), {
recursive: true,
force: true,
force: true
});

updateJsonFile(
Nodepath.join(artifactsPath, "rescript.json"),
["package-specs", "module"],
"commonjs"
);
updateJsonFile(Nodepath.join(artifactsPath, "rescript.json"), [
"package-specs",
"module"
], "commonjs");

updateJsonFile(
Nodepath.join(artifactsPath, "rescript.json"),
["suffix"],
".bs.js"
);
updateJsonFile(Nodepath.join(artifactsPath, "rescript.json"), ["suffix"], ".bs.js");

Execa.execaSync("npm", ["run", "res:build"], {
cwd: artifactsPath,
Execa.execaSync("npm", [
"run",
"res:build"
], {
cwd: artifactsPath
});

updateJsonFile(
Nodepath.join(artifactsPath, "package.json"),
["type"],
"commonjs"
);
updateJsonFile(Nodepath.join(artifactsPath, "package.json"), ["type"], "commonjs");

Fs.rmSync(Nodepath.join(artifactsPath, "lib"), {
recursive: true,
force: true,
force: true
});

Fs.rmSync(Nodepath.join(artifactsPath, "node_modules"), {
recursive: true,
force: true,
force: true
});

export {};
/* artifactsPath Not a pure module */
2 changes: 1 addition & 1 deletion packages/prepack/src/Prepack.res
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module Rollup = {
type t = {
input?: string,
@as("external")
external_?: array<Re.t>,
external_?: array<RegExp.t>,
}
}

Expand Down
35 changes: 23 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2d71949

Please sign in to comment.