Is it possible to require/import?
See original GitHub issueI’ve been using httpVueLoader for a side project where I just don’t need a compile step and it’s been very convenient!
As the app has been getting more complex, I’ve been wanting to modularize some parts, but require
doesn’t seem to work inside of a .Vue
file’s script
block. I’m assuming it’s not supported, but sort of hoping I’m just doing it wrong…
<script>
var mixins = require('./test.js');
module.exports = {
mixins,
});
</script>
Nothing actually breaks, but ./test.js
doesn’t get loaded and my mixins don’t get executed.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
JavaScript require vs import - Flexiple
One of the major differences between require() and import() is that require() can be called from anywhere inside the program whereas import() ...
Read more >JavaScript Require vs. Import - Bits and Pieces
1. Require statements can be called anywhere in the code ... Usually, we call the import or require statements at the beginning of...
Read more >Using Node.js require vs. ES6 import/export - Stack Overflow
Your answer is totally valid, but I think we're comparing two different characteristics. All import/export is converted to require , granted. But what...
Read more >Difference between node.js require and ES6 import and export
Require is Non-lexical, it stays where they have put the file. Import is lexical, it gets sorted to the top of the file....
Read more >Node.js: How to Use "Import" and "Require" in the Same File
Cases where it is necessary to use both “require” and “import” in a single file, are quite rare and it is generally not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello from the future! I’m a bit new to the vue/php world and am using your library to import components in. Is there any new feature allowing the es6 support for importing libraries? I’m guessing it could be more along the php/babel side not being able to compile things correctly. I get an unexpected token when importing within a .vue file then loading it inside a php file using vue SFC
it seems that Vue-Fuse component uses ES6 import at many places. http-vue-loader is only able to process the entry point of the component. Then you can try one of the following solution: