![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
vue-toolchain
Advanced tools
This is a small suite of tools for bundling and testing a Vue project. Its main advantages over vue-loader and others is:
.vue
files in Node<style>
into your Gulp pipeline.vue-toolchain/register
Example (change register.js
to vue-toolchain/register
)
You can use this with Mocha to launch tests that require Vue files. Say you have some tests, Button.spec.js
for Button.vue
. Assume Button.spec.js
looks like this:
const Button = require('./Button.vue').default;
const Vue = require('vue');
const vm = new Vue(Button);
vm.text = 'Click Me!';
vm.$mount();
expect(vm._vnode.children[0].text).toBe('Click me!')
You can use vue-toolchain
to run the tests in Node like this:
$ mocha -r vue-toolchain/register Button.spec.js
vue-toolchain/loader
Use the loader like any Webpack loader. Sourcemaps are supported, but many of the vue-loader
features like HMR are not yet supported. Stripping out CSS is specifically not supported because of a preference to use Gulp for styles (more on that below).
module.exports = {
module: {
rules: [
{test: /\.vue$/, use: 'vue-toolchain/loader'}
]
}
};
One benefit of using vue-toolchain
's loader is that unlike the upstream vue-loader
, it does not use a combination of 3 Webpack loaders and 3 JS modules for one component. vue-toolchain
's loader uses an alternate approach: using Babel, modify the AST of the component to add the render function. In large applications, this can save you tens of kilobytes.
vue-toolchain/gulp-vue-to-style-stream
You can pipe the .vue
files through this Gulp util in order to get styles out. Doing it this way allows you to have variables defined in other SCSS files which you can then use in your component <style>
. (If you do want to use variables, just make sure they concatenate in the right order - see the demo for how).
const gulp = require('gulp');
const vueToStyle = require('vue-toolchain/gulp-vue-to-style-stream');
const scss = require('gulp-sass');
const concat = require('gulp-concat');
gulp.task('scss', () => {
gulp.src('*.vue')
.pipe(vueToStyle())
.pipe(concat('styles.scss'))
.pipe(scss())
.pipe(gulp.dest('.'));
});
FAQs
Simplified toolchain for Vue development
We found that vue-toolchain demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.