-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Improvements to javascript and build process #5
base: main
Are you sure you want to change the base?
Conversation
Added prettier for consistent code formatting and applied formatting. (This accounts for most of the code changes) Updated javascript to simplify some of the environment detection Moved import of pako to top of file Ensure that performance object in node is not fully replaced and instead just `now` is replaced Added scripts to package.json for building and testing. Added source maps - this is nice for library consumers that need to debug Updated compatibility chart. globalThis bumped node from 8 to 12. Updated build process to automatically include type definition
{ | ||
// Include type definitions | ||
input: "./src/index.d.ts", | ||
output: [{ file: "dist/index.d.ts", format: "es" }], | ||
plugins: [dts()], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the only actual change to this file, everything else was just a formatting change from prettier
"scripts": { | ||
"build": "npm-run-all clean build:js build:go", | ||
"build:js": "rollup -c", | ||
"build:go": "cd cmd && GOOS=js GOARCH=wasm go build -ldflags=\"-s -w\" -o ../dist/excelize.wasm && cd ../dist && gzip -9 -v -c excelize.wasm > excelize.wasm.gz && rm excelize.wasm", | ||
"clean": "rm -rf dist", | ||
"test": "node test/test-nodejs.js" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any of these scripts can be executed by running npm run x
- e.x. npm run build
.
npm-run-all
is a library that allows running multiple npm commands without having to chain them together.
gzip -9 -v -c excelize.wasm > excelize.wasm.gz && rm excelize.wasm
is probably not cross-platform compatible, likely won't work on Windows.
@xuri - Hopefully I did not overstep any boundaries by raising this PR and I hope you find the changes valuable. |
Thanks for your pull request. This PR contains a lot of code and I need some time to review. |
@xuri - No problem, take your time. Let me know if you have any questions or if there is anything that I came up with that you disagree with. Thanks! |
PR Details
index.js
Description
now
is replacedRelated Issue
There is no open issue for this, since it is not really a feature or a bug. Happy to discuss changes here or open an issue if we would like to track an issue along with this PR.
Please let me know. 🙏
Motivation and Context
The
init
function was using a mix of legacy JS and modern JS. This PR cleans up these minor issues.The build process was not documented or automated, this PR includes documentation in the README and automates this using package.json scripts.
In addition, a test has been added to ensure that the built code works.
How Has This Been Tested
I added a file to test in NodeJS (just basic usage for now) and I have tested manually in a Typescript web project to ensure that the changes work correctly.
Types of changes
Checklist
We still have a lot of tests that would benefit from being written