Skip to content
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

Generate bundle.min.cjs in Node.js install script #3794

Merged
merged 1 commit into from Aug 1, 2021

Conversation

mjethani
Copy link
Contributor

@mjethani mjethani commented Aug 1, 2021

Following up from the discussion here: ghostery/adblocker#2091 (comment)

The Node.js install script now generates a bundle.min.cjs file.

@@ -22,5 +22,9 @@
"bugs": {
"url": "https://github.com/gorhill/uBlock/issues"
},
"homepage": "https://github.com/gorhill/uBlock#readme"
"homepage": "https://github.com/gorhill/uBlock#readme",
"dependencies": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that these dependencies are a bad idea. Ideally the benchmark package should do all of this on its own. But in the interest of moving things forward it's OK for now.

Copy link
Owner

Choose a reason for hiding this comment

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

I was happy to not have external dependencies... Maybe eventually this could be a special make target which would patch package.json to add those dependencies -- not sure if this makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this bundle should be provided at all in the end. I'll try to do this in the benchmark repo and if it works out alright then this stuff can be removed.

@@ -22,5 +22,9 @@
"bugs": {
"url": "https://github.com/gorhill/uBlock/issues"
},
"homepage": "https://github.com/gorhill/uBlock#readme"
"homepage": "https://github.com/gorhill/uBlock#readme",
"dependencies": {
Copy link
Owner

Choose a reason for hiding this comment

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

I was happy to not have external dependencies... Maybe eventually this could be a special make target which would patch package.json to add those dependencies -- not sure if this makes sense

@gorhill gorhill merged commit 297bcea into gorhill:master Aug 1, 2021
@mjethani mjethani deleted the generate-bundle-npm-install branch August 1, 2021 22:33
@mjethani
Copy link
Contributor Author

mjethani commented Aug 1, 2021

Follow-up here: ghostery/adblocker#2095

@gorhill
Copy link
Owner

gorhill commented Aug 1, 2021

I get an error when I do node install:

Error: Cannot find module 'minimist'
Require stack:
- /usr/share/nodejs/rollup/bin/src/index.js
...

Never mind, I realize I have to make install-nodejs.

// module.exports. Once all included files are written like ES modules, using
// export statements, this should no longer be necessary.
if (typeof module !== 'undefined' && typeof exports !== 'undefined') {
module.exports = exports;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gorhill sorry I used the wrong indentation level here.

I notice a few jshint comments in the source. Are you using this tool? Maybe you should add the configuration to the repo along with a lint target in Makefile.

Copy link
Owner

@gorhill gorhill Aug 2, 2021

Choose a reason for hiding this comment

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

.jshintrc is already present in the repo.

As for the lint command, I am going to have to read to find out best way to do this -- here is says to add

lint:
    ./node_modules/.bin/jshint ...

Which means I need to add a ./node_modules/.bin/jshint target as well I guess? My installation of jshint is outside the ublock project and I use a specific path to access the command in my text editor, not suitable for the public Makefile here.

Copy link
Contributor Author

@mjethani mjethani Aug 2, 2021

Choose a reason for hiding this comment

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

.jshintrc is already present in the repo.

Sorry, my bad!

Which means I need to add a ./node_modules/.bin/jshint target as well I guess? My installation of jshint is outside the ublock project and I use a specific path to access the command in my text editor, not suitable for the public Makefile here.

It's OK to expect people to install jshint manually via npm install -g jshint. Maybe this should be added to the CONTRIBUTING.md file.

As for the lint target, let me see how this works on the command line since I haven't used it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems JSHint removed indentation level checks a long time ago: https://github.com/jshint/jshint/releases/tag/2.5.0

I'll see if I can add some basic ESLint configuration that matches the JSHint configuration and also adds options for indentation, etc. to match the current coding style.

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.

None yet

2 participants