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

Replace utility functions with dedicated npm packages #766

Merged
merged 6 commits into from
Aug 14, 2018

Conversation

jansule
Copy link
Member

@jansule jansule commented Jul 12, 2018

BREAKING CHANGE

Description:

Extract utility functions and create dedicated npm packages (@terrestris/base-util, @terrestris/ol-util). Extraction aims at improving reusability of core functions within other projects.

Technically, all files except TestUtil.js were removed from src/Util/. All paths were updated (including *.spec.js) and dependencies to the packages were included.

Further information in this issue.

So far only ES6 version exists.

#762

@KaiVolland KaiVolland requested review from marcjansen and dnlkoch July 13, 2018 06:51
Copy link
Member

@dnlkoch dnlkoch left a comment

Choose a reason for hiding this comment

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

Very nice!

I added just a few minor issues you might want to check.

jest.config.js Outdated
@@ -1,3 +1,4 @@
const path = require('path');
Copy link
Member

Choose a reason for hiding this comment

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

Unused variable.

src/index.js Outdated
import { UndoUtil } from '@terrestris/base-util';
import { UrlUtil } from '@terrestris/base-util';
import { WfsFilterUtil } from '@terrestris/ol-util';
import { Logger } from '@terrestris/base-util';
Copy link
Member

Choose a reason for hiding this comment

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

I think all util imports should be removed from the index.js since all classes are imported directly from the corresponding util modules anyway.

@@ -36,5 +36,5 @@ module.exports = {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'file-loader'
}]
}
},
Copy link
Member

Choose a reason for hiding this comment

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

Please remove dangling comma.

@@ -36,5 +36,5 @@ module.exports = {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'file-loader'
}]
}
},
};
Copy link
Member

Choose a reason for hiding this comment

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

Not related to this PR, but please add a newline.

import StringUtil from '../../Util/StringUtil/StringUtil';
import AnimateUtil from '../../Util/AnimateUtil/AnimateUtil';
import Logger from '../../Util/Logger';
import { MapUtil } from '@terrestris/ol-util';
Copy link
Member

Choose a reason for hiding this comment

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

Unsure here, but I think in terms of bundle size it could be smarter to import the classes via the direct path, e.g. @terrestris/ol-util/MapUtil/MapUtil.

Maybe @amir-ba can verify this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would also suggest we stick to the habit of importing through direct paths. at least until we have react-geo in ES6

Copy link
Member

@KaiVolland KaiVolland left a comment

Choose a reason for hiding this comment

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

Two minor notes.

package.json Outdated
@@ -90,7 +90,7 @@
"validator": "10.4.0"
},
"devDependencies": {
"antd": "3.6.6",
"antd": "^3.7.0",
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the ^.

package.json Outdated
@@ -118,7 +118,7 @@
"less": "3.7.1",
"less-loader": "4.1.0",
"np": "3.0.4",
"ol": "4.6.5",
"ol": "^4.6.5",
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the ^.

@jansule jansule force-pushed the utilchanges branch 2 times, most recently from 59017e0 to 2a9db93 Compare August 13, 2018 08:51
jest.config.js Outdated
@@ -27,5 +27,6 @@ module.exports = {
'src/**/*.js',
'!src/**/*example*.*'
],
coverageDirectory: '<rootDir>/coverage'
coverageDirectory: '<rootDir>/coverage',
testURL: 'http://localhost/'
Copy link
Member

Choose a reason for hiding this comment

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

testURL is already present in the current master and can be removed here.

  - Remove everything except TestUtil.js from src/Util/
  - update dependencies to corresponding npm packages
  - update tests
Index.js does not import utility modules anymore. Now, needed utilities will be directly imported within the respective classes. Furthermore, minor changes e.g. removing dangling commas were done.
Due to a minor release of jsdom, jest cannot handle default testURL anymore. testURL now needs to be specified explicitely. Here, localhost was used.
@dnlkoch
Copy link
Member

dnlkoch commented Aug 14, 2018

Thanks again @jansule!

@dnlkoch dnlkoch merged commit 3bc6730 into terrestris:master Aug 14, 2018
hblitza pushed a commit that referenced this pull request Oct 19, 2022
…29.0.0

chore(deps-dev): bump jest from 28.1.3 to 29.0.0
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.

4 participants