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

es6 import of a language file does not work #5092

Open
axten opened this Issue Apr 12, 2018 · 9 comments

Comments

Projects
None yet
5 participants
@axten
Copy link
Contributor

axten commented Apr 12, 2018

Description

if I try to import a language file I got ReferenceError: videojs is not defined

so any lang file should have an import statement befor videojs to fix this.
besides that, a work around could be to provide the pure json files in videojs build.
this also would be great to extend a language during project build.

Steps to reproduce

just do

import videojs from 'video.js';
import 'video.js/dist/lang/de';

Results

Expected

should work as expected

Actual

it breaks

Additional Information

videojs: 6.8.0

@axten axten changed the title es6 import of an language file does not work es6 import of a language file does not work Apr 12, 2018

@gkatsev

This comment has been minimized.

Copy link
Member

gkatsev commented Apr 12, 2018

Oops, I guess the language files we build expect videojs to be available globally. We the build system for them a long time ago before importing/requiring and bundling was popular. We should revisit it soon.

@axten

This comment has been minimized.

Copy link
Contributor Author

axten commented Apr 12, 2018

so in the meantime it would be great to have the pure json files in the npm package

@hojas

This comment has been minimized.

Copy link

hojas commented May 28, 2018

+1

@stale

This comment has been minimized.

Copy link

stale bot commented Aug 10, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 10, 2018

@gkatsev gkatsev added confirmed and removed wontfix labels Aug 10, 2018

@gkatsev

This comment has been minimized.

Copy link
Member

gkatsev commented Aug 10, 2018

@axten want to submit a PR that adds the json files to the npm publish?

@axten

This comment has been minimized.

Copy link
Contributor Author

axten commented Aug 11, 2018

I'm not shure how this works in your pipeline

@michelson

This comment has been minimized.

Copy link

michelson commented Sep 8, 2018

👍

@eranshmil eranshmil referenced this issue Nov 5, 2018

Merged

feat(lang): es6 import of a language file #5549

1 of 7 tasks complete

gkatsev added a commit that referenced this issue Nov 5, 2018

feat(lang): copy language JSON files into dist dir (#5549)
This helps with ESM import and bundler users can then import the JSON files directly and register the languages manually. For example:
```js
import es from 'video.js/dist/lang/es.json';

videojs(element, {
  language: 'es',
  languages: {
    es
  }
});
```

Related issue: #5092
@eranshmil

This comment has been minimized.

Copy link
Contributor

eranshmil commented Nov 9, 2018

I think you could close this issue since PR #5549 has been merged.

@gkatsev

This comment has been minimized.

Copy link
Member

gkatsev commented Nov 9, 2018

I think I'd like to keep this open for a bit longer to see if we can figure out a better solution.
Potentially, compile the json files into a .mjs file that imports video.js at the top of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment