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

Import wave-surfer using webpack instead of including it in third_party.js file #8922

Merged
merged 6 commits into from
Mar 27, 2020
Merged

Import wave-surfer using webpack instead of including it in third_party.js file #8922

merged 6 commits into from
Mar 27, 2020

Conversation

nishantwrp
Copy link
Contributor

Overview

This PR does the following: Imports wave-surfer using webpack instead of third_party_js.

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The linter/Karma presubmit checks have passed locally on your machine.
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
    • This lets reviewers restart your CircleCI tests for you.
  • The PR is made from a branch that's not called "develop".

PR Pointers

  • Oppiabot will notify you when you don't add a PR_CHANGELOG label. If you are unable to do so, please @-mention a code owner (who will be in the Reviewers list), or ask on Gitter.
  • For what code owners will expect, see the Code Owner's wiki page.
  • Make sure your PR follows conventions in the style guide, otherwise this will lead to review delays
  • Never force push. If you do, your PR will be closed.

@oppiabot
Copy link

oppiabot bot commented Mar 24, 2020

Assigning @vojtechjelinek for the first-pass review of this pull request. Thanks!

Copy link
Member

@kevintab95 kevintab95 left a 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');
Copy link
Member

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kevintab95 Fixed this.

Copy link
Contributor

@kevinlee12 kevinlee12 left a 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.

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a 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');
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link

codecov bot commented Mar 25, 2020

Codecov Report

Merging #8922 into develop will increase coverage by <.01%.
The diff coverage is 66.67%.

@@             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
Flag Coverage Δ
#frontend 53.06% <66.67%> (ø) ⬆️
Impacted Files Coverage Δ
...emplates/third-party-imports/wave-surfer.import.ts 100% <100%> (ø)
...translation-bar/audio-translation-bar.directive.ts 6.21% <50%> (+0.29%) ⬆️

@nishantwrp nishantwrp closed this Mar 26, 2020
@nishantwrp nishantwrp reopened this Mar 26, 2020
Copy link
Member

@kevintab95 kevintab95 left a 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!

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a 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');
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@ankita240796 ankita240796 left a 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!

@ankita240796 ankita240796 removed their assignment Mar 26, 2020
@kevinlee12 kevinlee12 merged commit fce21b2 into oppia:develop Mar 27, 2020
FlorinBalint pushed a commit to FlorinBalint/oppia that referenced this pull request Mar 27, 2020
…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
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.

7 participants