-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Import wave-surfer using webpack instead of including it in third_party.js file #8922
Conversation
Assigning @vojtechjelinek for the first-pass review of this pull request. Thanks! |
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 one minor comment. PTAL @nishantwrp.
@@ -0,0 +1,2 @@ | |||
window.WaveSurfer = require( | |||
'../../../third_party/static/wave-surfer-js-2.2.1/wavesurfer.min.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.
Relative imports are not allowed. The lint check for this doesn't work properly but #8870 should fix it. But meanwhile, can you please correct this instance? Thanks!
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.
@kevintab95 Fixed this.
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.
lgtm for .github/CODEOWNERS
only.
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.
Thanks! Two comments.
@@ -48,6 +48,7 @@ require('services/context.service.ts'); | |||
require('services/editability.service.ts'); | |||
require('services/id-generation.service.ts'); | |||
require('services/user.service.ts'); | |||
require('third-party-imports/wave-surfer.scripts.ts'); |
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.
rename this to wave-surfer.import.ts
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.
also, does it make sense to load the variable into window.WaveSurfer
? Can we just load it to a local variable named WaveSurfer
here and use it?
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.
@vojtechjelinek I think in my GSoC proposal we agreed to follow *scripts.ts naming?
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 think that the final conclusion was to use *.import.ts
for all the files that only contain requires/imports. I may have made a mistake in some of my comments. But I think that the import naming is much more decriptive.
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.
@vojtechjelinek Renamed the file. But had a doubt about your second comment.
Are you saying to modify the wave-surfer.import.ts
to something like
module.exports = require(
'static/wave-surfer-js-2.2.1/wavesurfer.min.js');
and modifying the require statement in audio-translation-bar.directive.ts
to something like
var WaveSurfer = require('third-party-imports/wave-surfer.import.ts');
and use that in that file?
In my opinion, I think it looks weird we don't assign a variable to require statements in any other file. I think we should do that work in .import.ts
file itself. What do you think?
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.
We actually use this for example for the hashes already
let hashes = require('hashes.json'); |
from my POV it doesn't make sense to make the library available for the whole window namespace if it is required just in the one file.
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.
Ok, Makes sense. I'll update the code.
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.
@vojtechjelinek Done! Also removed the custom declarations as they are no longer needed.
Codecov Report
@@ Coverage Diff @@
## develop #8922 +/- ##
===========================================
+ Coverage 53.06% 53.06% +<.01%
===========================================
Files 862 863 +1
Lines 35502 35504 +2
Branches 4212 4212
===========================================
+ Hits 18838 18840 +2
Misses 15746 15746
Partials 918 918
|
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.
Code-owner file LGTM, thanks @nishantwrp!
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.
Thanks! Just one small comment.
@@ -48,6 +48,7 @@ require('services/context.service.ts'); | |||
require('services/editability.service.ts'); | |||
require('services/id-generation.service.ts'); | |||
require('services/user.service.ts'); | |||
var WaveSurfer = require('third-party-imports/wave-surfer.import.ts'); |
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.
maybe use const
instead of var
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.
Done
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.
LGTM from code-owner's perspective, Thanks @nishantwrp!
…rty.js file (oppia#8922) * Import wave-surfer using webpack instead of including it in third_party.js file * Codeowners * Removed Relative Imports * Add file to coverage tests * Load WaveSurfer in only one file * var -> const
Overview
This PR does the following: Imports wave-surfer using webpack instead of third_party_js.
Essential Checklist
PR Pointers