# Existing JS module import into ES6 plugin

**URL:** https://meta.discourse.org/t/existing-js-module-import-into-es6-plugin/52713
**Category:** Development
**Created:** [November 9, 2016, 4:38pm UTC](https://meta.discourse.org/t/existing-js-module-import-into-es6-plugin/52713 "2016-11-09T16:38:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ntadej](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ntadej/32/116716_2.png) [@ntadej](https://meta.discourse.org/u/ntadej)
#### Post date: [November 9, 2016, 4:38pm UTC](https://meta.discourse.org/t/existing-js-module-import-into-es6-plugin/52713/1 "2016-11-09T16:38:04Z")

</div>

I’m writing a markdown plugin which needs an external JS for server side code. How to import the module properly so it will be detected by `mini_racer`. I can either import JS module (as git submodule) or already compiled min.js.

If I just do `register_asset` ‘file.js’, :server\_side it works in browser, but not when I try to rebuild post HTML.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 21, 2016, 6:31pm UTC](https://meta.discourse.org/t/existing-js-module-import-into-es6-plugin/52713/2 "2016-11-21T18:31:08Z")

</div>

This is an example of plugin that modifies post cooking:

[https://github.com/discourse/discourse/blob/master/plugins/poll/assets/javascripts/lib/discourse-markdown/poll.js.es6](https://github.com/discourse/discourse/blob/master/plugins/poll/assets/javascripts/lib/discourse-markdown/poll.js.es6)

---

<div class="post-metadata">

### Author: ![ntadej](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ntadej/32/116716_2.png) [@ntadej](https://meta.discourse.org/u/ntadej)
#### Post date: [November 21, 2016, 6:59pm UTC](https://meta.discourse.org/t/existing-js-module-import-into-es6-plugin/52713/3 "2016-11-21T18:59:31Z")

</div>

Thank you for your example. Here you included full function inline. Is there a way to “require” it to have a cleaner plugin?

---

<div class="post-metadata">

### Author: ![ntadej](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ntadej/32/116716_2.png) [@ntadej](https://meta.discourse.org/u/ntadej)
#### Post date: [November 25, 2016, 6:48pm UTC](https://meta.discourse.org/t/existing-js-module-import-into-es6-plugin/52713/4 "2016-11-25T18:48:01Z")

</div>

If I copy the (un)minified code of the library directly to plugin ES6 file, it fails.
