-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Specify import require paths (continuation of #1941) #1962
Conversation
Specify package type as `commonjs` (It's good to be specific)
Remove ./number.js (You can use the compiled ones in `./lib/*`) Tell node that the `esm` directory is type `module` and enable tree shaking. Remove unused files from packages `files` property
….com/GreenImp/mathjs into GreenImp-feature/specify-import-require-paths # Conflicts: # package-lock.json # package.json # src/expression/embeddedDocs/embeddedDocs.js # src/factoriesAny.js # src/function/algebra/solver/utils/solveValidation.js
- Refactor `bundleAny` into `defaultInstance.js` and `browserBundle.cjs` - Refactor unit tests to be able to run with plain nodejs (no transpiling) - Fix browser examples
'browser', | ||
'docs' | ||
bundle, | ||
generateDocs |
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.
Just thought it worth mentioning, I set these to the string names of the tasks that I created above, so Gulp will run those tasks. That way, if one of the tasks changes (Like with the browser compiling changing from bundle, minify
to just bundle
) you only need to change the individual task, and not the one here as well.
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.
Yes, true. Formerly the 'browser'
task did two things: bundle and minify. There is only one left now: bundle, so I thought like let's remove this indirection. I think we can maybe remove gulp.task('browser', bundle)
because it's not used anywhere externally from the package.json scripts. The task 'docs' only does one thing (generateDocs) but is actually used in the package.json scripts.
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.
Yeah, I initially created those tasks because I found that I kept needing to clean out things and only rebuild certain things when I was testing, so it made it a bit easier.
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.
Ah! Makes sense. If you like it better to call the gulp tasks instead of the function it's totally fine with me, for me both is ok.
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.
I don't really mind. It's a minor thing anyway, so might as well leave it as is for now.
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1. **This update includes a security fix.** - [Release notes](https://github.com/bitinn/node-fetch/releases) - [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md) - [Commits](node-fetch/node-fetch@v2.6.0...v2.6.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
I think this PR is now ready to be merged. I hope to publish a release candidate for |
Bumps [karma](https://github.com/karma-runner/karma) from 5.2.1 to 5.2.2. - [Release notes](https://github.com/karma-runner/karma/releases) - [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md) - [Commits](karma-runner/karma@v5.2.1...v5.2.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Thanks for sorting the deprecation messages on the old files! I just didn't seem to have the time to get around to it. |
I merged this PR now in the |
I've I'm able to compile my library, without including mathjs in the bundle, but have it as a dependency of my project. So when installing my library it brings down mathjs and everything still works as if it was bundled And my Jest tests still seem to work as well! That's exactly what I needed from these changes, so I'm really happy. It's looking really good! Thanks. |
That's great news, thanks for testing it out Lee 👍 |
I've finally published the first beta version on npm: I'm still thinking about how we can make it easier or more obvious that all imports now require to have the Maybe it's possible to create a lint rule to check for that (not possible with standardjs, so we may have to switch to eslint-config-standard for example). |
That's fab! I'm really looking forward to being able to use v8. I'm not sure I understand the problem with file extensions?
But you can also import various other files with the full path (Including extension). Or am I misunderstanding the issue? |
@GreenImp I mean not when consuming mathjs as a library, but when you're developing mathjs itself (like add a new function). When creating a new file in the mathjs repo, you have to be careful to add the file extensions. |
For now, I've added a section "Develop" in the README.md explaining this. I think it's a generic issue that we'll see with more libraries when more and libraries start being written in plain ESM. |
I've just published |
Thanks @josdejong that's brilliant! Really appreciate your time in getting this all sorted and merged in. |
Thanks! Good to hear it's working smoothly in your project. |
@GreenImp I continued your PR and got everything working I think.
/lib/cjs/package.json
and/lib/browser/package.json
during the buildStill to do:
math.js
Reference #1941