Skip to content

Update for PureScript 0.15 #96

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

Merged
merged 8 commits into from
May 16, 2022
Merged

Update for PureScript 0.15 #96

merged 8 commits into from
May 16, 2022

Conversation

thomashoneyman
Copy link
Collaborator

This PR updates the library and executable to work with PureScript 0.15. Two notable points:

  1. There were changes to src to accommodate type-level ints, so this will require the next version to be 0.9.0
  2. This is pointing at the node-esm branch of node-workerbees, as that library doesn't have a ES modules compatible release yet (we're waiting on it to be able to support non-bundled output when executing a worker). Since it's only used for the executable here that's not a problem for library consumers.

else do
let contents = Json.stringifyWithIndent 2 $ FormatOptions.toJson cliOptions
FS.writeTextFile UTF8 rcFileName $ contents <> "\n"
rcStats <- Aff.try $ FS.stat rcFileName
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

exists was removed as part of the 0.15 updates, as its been recommended against by Node for years. This instead tries to stat the file, and if that throws an exception (the file is missing) then we write the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you use liftEffect $ FSSync.exists?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is also possible, but we can use proper async here via stat (which is also used elsewhere in this file)

bin/Main.purs Outdated
, export: "main"
}
]
FS.stat bundleLocation $> Worker.unsafeWorkerFromPath bundleLocation
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're now expected to always bundle before running the local cli.

Copy link
Owner

Choose a reason for hiding this comment

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

I think we should keep this logic, but add an additional JS entry point that invokes the worker from output. This is useful for me during dev.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

, """Type.Function.($) type 0"""
, """Type.Prelude.(+) type 0"""
, """Type.Row.(+) type 0"""
[ """"""
Copy link
Owner

Choose a reason for hiding this comment

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

What happened here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yikes! I didn't notice right away, but obviously generating the operators isn't working. I'm debugging locally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's failing because of removing npm install on my system, which also means no spago install, and therefore there's no .spago directory to read from when executing this in the tmpdir:

./bin/index.js generate-operators '.spago/*/*/src/**/*.purs'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 1cf24d1

@@ -1 +1,3 @@
exports.version = require("../../package.json").version;
import packageJson from "../../package.json" assert { type: "json" };
Copy link
Collaborator Author

@thomashoneyman thomashoneyman May 15, 2022

Choose a reason for hiding this comment

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

Copy link
Owner

@natefaubion natefaubion May 16, 2022

Choose a reason for hiding this comment

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

One way around this, would be to add a version script. I use npm version to bump the package.json, and as part of the workflow we could write a new Versions.js with the updated version env variable. For example:

"version": "echo 'export const version = \"v'$npm_package_version'\";' > ./bin/Bin/Version.js"

https://docs.npmjs.com/cli/v8/commands/npm-version#description

Copy link
Collaborator Author

@thomashoneyman thomashoneyman May 16, 2022

Choose a reason for hiding this comment

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

I've moved the prepublishOnly script to be preversion and added tests to it, added your recommended line here as version, and added a git push as suggested by the NPM docs in the link you provided to postversion. Running npm run version executes all three. If you'd prefer something different please let me know what you'd like instead.

4d1eaf2

@@ -0,0 +1,8 @@
#!/usr/bin/env -S node --experimental-json-modules
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@thomashoneyman
Copy link
Collaborator Author

@natefaubion I've added a separate entrypoint, ./bin/index.dev.js, which refers to the output directory and which can be used without bundling.

@thomashoneyman thomashoneyman merged commit c8789d9 into main May 16, 2022
@thomashoneyman thomashoneyman deleted the trh/purs-0.15 branch May 16, 2022 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants