Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.

Comments

Refactor and remove hard-coded require('riot')#1

Open
al-the-x wants to merge 1 commit intomarcel0ll:masterfrom
al-the-x:al-the-x--no-require-riot
Open

Refactor and remove hard-coded require('riot')#1
al-the-x wants to merge 1 commit intomarcel0ll:masterfrom
al-the-x:al-the-x--no-require-riot

Conversation

@al-the-x
Copy link

@al-the-x al-the-x commented Jun 1, 2018

Because I need to require('riot/riot.csp') for use inside a Chrome Extension instead, and if I just add the import statement to the <script> content of the tag, riot.compile lifts it appropriately, e.g.

<some-tag>
  <h1> Some Tag </h1>
  <script>
    import riot from 'riot';
  </script>
</some-tag>

Compiles to:

import riot from 'riot';
riot.tag2('some-tag', '<h1> Some Tag </h1>', '', '', function(opts) {
});

While that means that I have to import inside every tag, that's not a big deal to me. Maybe it could be a plugin-specific configuration option, e.g. package.riot.import of:

  • true (default) - include standard import preamble
  • false - don't include ANY preamble
  • 'string' - include preamble as import riot from 'string'

Thoughts?

Because I need to `require('riot/riot.csp')` for use inside a Chrome Extension instead.
@marcel0ll
Copy link
Owner

I know I am late on this, but the preamble idea is very good.
I will look into this!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants