first commit
This commit is contained in:
commit
eb2f504652
32490 changed files with 5731109 additions and 0 deletions
21
node_modules/@quasar/vite-plugin/LICENSE
generated
vendored
Normal file
21
node_modules/@quasar/vite-plugin/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021-present Razvan Stoenescu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
51
node_modules/@quasar/vite-plugin/README.md
generated
vendored
Normal file
51
node_modules/@quasar/vite-plugin/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||

|
||||
|
||||
# Quasar Framework plugin for Vite
|
||||
|
||||
> Warning! Current limitations:
|
||||
> * SSR builds with Quasar Vite plugin are not yet supported.
|
||||
> * Usage with RTL Quasar language packs is not yet supported.
|
||||
|
||||
<img src="https://img.shields.io/npm/v/%40quasar/vite-plugin.svg?label=@quasar/vite-plugin">
|
||||
|
||||
[](https://chat.quasar.dev)
|
||||
<a href="https://forum.quasar.dev" target="_blank"><img src="https://img.shields.io/badge/community-forum-brightgreen.svg"></a>
|
||||
[](https://good-labs.github.io/greater-good-affirmation)
|
||||
|
||||
## Installation
|
||||
|
||||
https://quasar.dev/start/vite-plugin
|
||||
|
||||
## Supporting Quasar
|
||||
Quasar Framework is an MIT-licensed open source project. Its ongoing development is made possible thanks to the support by these awesome [backers](https://github.com/rstoenescu/quasar-framework/blob/dev/backers.md).
|
||||
|
||||
**Please read our manifest on [Why donations are important](https://quasar.dev/why-donate)**. If you'd like to become a donator, check out [Quasar Framework's Donator campaign](https://donate.quasar.dev).
|
||||
|
||||
## Documentation
|
||||
|
||||
Head on to the Quasar Framework official website: [https://quasar.dev](https://quasar.dev)
|
||||
|
||||
## Stay in Touch
|
||||
|
||||
For latest releases and announcements, follow on Twitter: [@quasarframework](https://twitter.com/quasarframework)
|
||||
|
||||
## Chat Support
|
||||
|
||||
Ask questions at the official community Discord server: [https://chat.quasar.dev](https://chat.quasar.dev)
|
||||
|
||||
## Community Forum
|
||||
|
||||
Ask questions at the official community forum: [https://forum.quasar.dev](https://forum.quasar.dev)
|
||||
|
||||
## Contributing
|
||||
|
||||
I'm excited if you want to contribute to Quasar under any form (report bugs, write a plugin, fix an issue, write a new feature). Please read the [Contributing Guide](../CONTRIBUTING.md).
|
||||
|
||||
## Semver
|
||||
Quasar is following [Semantic Versioning 2.0](https://semver.org/).
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2021-present Razvan Stoenescu
|
||||
|
||||
[MIT License](http://en.wikipedia.org/wiki/MIT_License)
|
||||
468
node_modules/@quasar/vite-plugin/dist/index.cjs
generated
vendored
Normal file
468
node_modules/@quasar/vite-plugin/dist/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,468 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var node_fs = require('node:fs');
|
||||
var node_path = require('node:path');
|
||||
var node_module = require('node:module');
|
||||
var vite = require('vite');
|
||||
var importTransformation = require('quasar/dist/transforms/import-transformation.js');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var importTransformation__default = /*#__PURE__*/_interopDefaultLegacy(importTransformation);
|
||||
|
||||
const require$1 = node_module.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
|
||||
|
||||
const quasarPath = node_path.dirname(require$1.resolve('quasar/package.json'));
|
||||
|
||||
const { version } = JSON.parse(
|
||||
node_fs.readFileSync(node_path.join(quasarPath, 'package.json'), 'utf-8')
|
||||
);
|
||||
|
||||
function getViteConfig (runMode, viteMode, externalViteCfg) {
|
||||
const viteCfg = {
|
||||
define: {
|
||||
__QUASAR_VERSION__: `'${ version }'`,
|
||||
__QUASAR_SSR__: false,
|
||||
__QUASAR_SSR_SERVER__: false,
|
||||
__QUASAR_SSR_CLIENT__: false
|
||||
}
|
||||
};
|
||||
|
||||
// Set this to the default value only if it's not already set.
|
||||
// @quasar/app-vite configures this by itself when it needs it.
|
||||
if (!externalViteCfg.define || externalViteCfg.define.__QUASAR_SSR_PWA__ === void 0) {
|
||||
viteCfg.define.__QUASAR_SSR_PWA__ = false;
|
||||
}
|
||||
|
||||
if (runMode === 'ssr-server') {
|
||||
Object.assign(viteCfg.define, {
|
||||
__QUASAR_SSR__: true,
|
||||
__QUASAR_SSR_SERVER__: true
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Alias "quasar" package to its dev file (which has flags)
|
||||
// to reduce the number of HTTP requests while in DEV mode
|
||||
if (viteMode !== 'production') {
|
||||
viteCfg.resolve = {
|
||||
alias: [
|
||||
{ find: /^quasar$/, replacement: 'quasar/dist/quasar.esm.js' }
|
||||
]
|
||||
};
|
||||
}
|
||||
else {
|
||||
viteCfg.optimizeDeps = {
|
||||
exclude: [ 'quasar' ]
|
||||
};
|
||||
}
|
||||
|
||||
if (runMode === 'ssr-client') {
|
||||
Object.assign(viteCfg.define, {
|
||||
__QUASAR_SSR__: true,
|
||||
__QUASAR_SSR_CLIENT__: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return viteCfg
|
||||
}
|
||||
|
||||
const importQuasarRegex = /import\s*\{([\w,\s]+)\}\s*from\s*(['"])quasar\2;?/g;
|
||||
|
||||
/**
|
||||
* Transforms JS code where importing from 'quasar' package
|
||||
* Example:
|
||||
* import { QBtn } from 'quasar'
|
||||
* -> import QBtn from 'quasar/src/components/QBtn.js'
|
||||
*/
|
||||
function mapQuasarImports (code, importMap = {}) {
|
||||
return code.replace(
|
||||
importQuasarRegex,
|
||||
(_, match) => match
|
||||
.split(',')
|
||||
.map(identifier => {
|
||||
const data = identifier.split(' as ');
|
||||
const importName = data[ 0 ].trim();
|
||||
|
||||
// might be an empty entry like below
|
||||
// (notice useQuasar is followed by a comma)
|
||||
// import { QTable, useQuasar, } from 'quasar'
|
||||
if (importName === '') {
|
||||
return ''
|
||||
}
|
||||
|
||||
const importAs = data[ 1 ] !== void 0
|
||||
? data[ 1 ].trim()
|
||||
: importName;
|
||||
|
||||
importMap[ importName ] = importAs;
|
||||
return `import ${ importAs } from '${ importTransformation__default["default"](importName) }';`
|
||||
})
|
||||
.join('')
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms JS code where importing from 'quasar' package
|
||||
* Example:
|
||||
* import { QBtn } from 'quasar'
|
||||
* -> add to importMap & importList & remove original import statement
|
||||
* (removing original is required so that the end file will have
|
||||
* only one import from Quasar statement)
|
||||
*/
|
||||
function removeQuasarImports (code, importMap, importSet, reverseMap) {
|
||||
return code.replace(
|
||||
importQuasarRegex,
|
||||
(_, match) => {
|
||||
match.split(',').forEach(identifier => {
|
||||
const data = identifier.split(' as ');
|
||||
const importName = data[ 0 ].trim();
|
||||
|
||||
// might be an empty entry like below
|
||||
// (notice useQuasar is followed by a comma)
|
||||
// import { QTable, useQuasar, } from 'quasar'
|
||||
if (importName !== '') {
|
||||
const importAs = data[ 1 ] !== void 0
|
||||
? data[ 1 ].trim()
|
||||
: importName;
|
||||
|
||||
importSet.add(importName + (importAs !== importName ? ` as ${ importAs }` : ''));
|
||||
importMap[ importName ] = importAs;
|
||||
reverseMap[ importName.replace(/-/g, '_') ] = importAs;
|
||||
}
|
||||
});
|
||||
|
||||
// we registered the original import and we
|
||||
// remove this one to avoid duplicate imports from Quasar
|
||||
return ''
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const autoImportData = JSON.parse(
|
||||
node_fs.readFileSync(node_path.join(quasarPath, 'dist/transforms/auto-import.json'), 'utf-8')
|
||||
);
|
||||
|
||||
const compRegex = {
|
||||
kebab: new RegExp(`_resolveComponent\\("${ autoImportData.regex.kebabComponents }"\\)`, 'g'),
|
||||
pascal: new RegExp(`_resolveComponent\\("${ autoImportData.regex.pascalComponents }"\\)`, 'g'),
|
||||
combined: new RegExp(`_resolveComponent\\("${ autoImportData.regex.components }"\\)`, 'g')
|
||||
};
|
||||
|
||||
const dirRegex = new RegExp(`_resolveDirective\\("${ autoImportData.regex.directives.replace(/v-/g, '') }"\\)`, 'g');
|
||||
const lengthSortFn = (a, b) => b.length - a.length;
|
||||
|
||||
function vueTransform (content, autoImportComponentCase, useTreeshaking) {
|
||||
const importSet = new Set();
|
||||
const importMap = {};
|
||||
|
||||
const compList = [];
|
||||
const dirList = [];
|
||||
|
||||
const reverseMap = {};
|
||||
const jsImportTransformed = useTreeshaking === true
|
||||
? mapQuasarImports(content, importMap)
|
||||
: removeQuasarImports(content, importMap, importSet, reverseMap);
|
||||
|
||||
let code = jsImportTransformed
|
||||
.replace(compRegex[ autoImportComponentCase ], (_, match) => {
|
||||
const name = autoImportData.importName[ match ];
|
||||
const reverseName = match.replace(/-/g, '_');
|
||||
|
||||
if (importMap[ name ] === void 0) {
|
||||
importSet.add(name);
|
||||
reverseMap[ reverseName ] = name;
|
||||
}
|
||||
else {
|
||||
reverseMap[ reverseName ] = importMap[ name ];
|
||||
}
|
||||
|
||||
compList.push(reverseName);
|
||||
return ''
|
||||
})
|
||||
.replace(dirRegex, (_, match) => {
|
||||
const name = autoImportData.importName[ 'v-' + match ];
|
||||
const reverseName = match.replace(/-/g, '_');
|
||||
|
||||
if (importMap[ name ] === void 0) {
|
||||
importSet.add(name);
|
||||
reverseMap[ reverseName ] = name;
|
||||
}
|
||||
else {
|
||||
reverseMap[ reverseName ] = importMap[ name ];
|
||||
}
|
||||
|
||||
dirList.push(reverseName);
|
||||
return ''
|
||||
});
|
||||
|
||||
if (compList.length !== 0) {
|
||||
const list = compList.sort(lengthSortFn).join('|');
|
||||
code = code
|
||||
.replace(new RegExp(`const _component_(${ list }) = `, 'g'), '')
|
||||
.replace(new RegExp(`_component_(${ list })`, 'g'), (_, match) => reverseMap[ match ]);
|
||||
}
|
||||
|
||||
if (dirList.length !== 0) {
|
||||
const list = dirList.sort(lengthSortFn).join('|');
|
||||
code = code
|
||||
.replace(new RegExp(`const _directive_(${ list }) = `, 'g'), '')
|
||||
.replace(new RegExp(`_directive_(${ list })`, 'g'), (_, match) => reverseMap[ match ]);
|
||||
}
|
||||
|
||||
if (importSet.size === 0) {
|
||||
return code
|
||||
}
|
||||
|
||||
const importList = [ ...importSet ];
|
||||
const codePrefix = useTreeshaking === true
|
||||
? importList.map(name => `import ${ name } from '${ importTransformation__default["default"](name) }'`).join(';')
|
||||
: `import {${ importList.join(',') }} from 'quasar'`;
|
||||
|
||||
return codePrefix + ';' + code
|
||||
}
|
||||
|
||||
function createScssTransform (fileExtension, sassVariables) {
|
||||
const sassImportCode = [ '@import \'quasar/src/css/variables.sass\'', '' ];
|
||||
|
||||
if (typeof sassVariables === 'string') {
|
||||
sassImportCode.unshift(`@import '${ sassVariables }'`);
|
||||
}
|
||||
|
||||
const prefix = fileExtension === 'sass'
|
||||
? sassImportCode.join('\n')
|
||||
: sassImportCode.join(';\n');
|
||||
|
||||
return content => {
|
||||
const useIndex = Math.max(
|
||||
content.lastIndexOf('@use '),
|
||||
content.lastIndexOf('@forward ')
|
||||
);
|
||||
|
||||
if (useIndex === -1) {
|
||||
return prefix + content
|
||||
}
|
||||
|
||||
const newLineIndex = content.indexOf('\n', useIndex);
|
||||
|
||||
if (newLineIndex !== -1) {
|
||||
const index = newLineIndex + 1;
|
||||
return content.substring(0, index) + prefix + content.substring(index)
|
||||
}
|
||||
|
||||
return content + '\n' + prefix
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* vue: () => boolean;
|
||||
* template: () => boolean;
|
||||
* script: (extensions?: string | string[]) => boolean;
|
||||
* style: (extensions?: string | string[]) => boolean;
|
||||
* }} ViteQueryIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see https://github.com/vitejs/vite/blob/364aae13f0826169e8b1c5db41ac6b5bb2756958/packages/plugin-vue/src/utils/query.ts - source of inspiration
|
||||
* @example
|
||||
* '/absolute/path/src/App.vue' // Can contain combined template&script -> template: true, script: true, style: false
|
||||
* '/absolute/path/src/App.vue?vue&type=script&lang.js' // Only contains script -> template: false, script: true, style: false
|
||||
* '/absolute/path/src/App.vue?vue&type=style&lang.sass' // Only contains style -> template: false, script: false, style: true
|
||||
* '/absolute/path/src/script.js' // Only contains script -> template: false, script: true, style: false
|
||||
* '/absolute/path/src/index.scss' // Only contains style -> template: false, script: false, style: true
|
||||
*
|
||||
* @param {string} id
|
||||
* @returns {{ filename: string; query: { [key: string]: string; }; is: ViteQueryIs }}
|
||||
*/
|
||||
function parseViteRequest (id) {
|
||||
const [ filename, rawQuery ] = id.split('?', 2);
|
||||
const query = Object.fromEntries(new URLSearchParams(rawQuery));
|
||||
|
||||
const is = query.raw !== void 0
|
||||
? {
|
||||
// if it's a ?raw request, then don't touch it at all
|
||||
vue: () => false,
|
||||
template: () => false,
|
||||
script: () => false,
|
||||
style: () => false
|
||||
}
|
||||
: (
|
||||
query.vue !== void 0 // is vue query?
|
||||
? {
|
||||
// Almost all code might get merged into a single request with no 'type' (App.vue?vue)
|
||||
// or stay with their original 'type's (App.vue?vue&type=script&lang.ts)
|
||||
vue: () => true,
|
||||
|
||||
template: () => (
|
||||
query.type === void 0
|
||||
|| query.type === 'template'
|
||||
// On prod, TS code turns into a separate 'script' request.
|
||||
// See: https://github.com/vitejs/vite/pull/7909
|
||||
|| (query.type === 'script' && (query[ 'lang.ts' ] !== void 0 || query[ 'lang.tsx' ] !== void 0))
|
||||
),
|
||||
|
||||
script: (extensions = scriptExt) => (
|
||||
(query.type === void 0 || query.type === 'script')
|
||||
&& isOfExt({ query, extensions }) === true
|
||||
),
|
||||
|
||||
style: (extensions = styleExt) => (
|
||||
query.type === 'style'
|
||||
&& isOfExt({ query, extensions }) === true
|
||||
)
|
||||
}
|
||||
: {
|
||||
vue: () => isOfExt({ extensions: vueExt, filename }),
|
||||
template: () => isOfExt({ filename, extensions: vueExt }),
|
||||
script: (extensions = scriptExt) => isOfExt({ filename, extensions }),
|
||||
style: (extensions = styleExt) => isOfExt({ filename, extensions })
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
filename,
|
||||
query,
|
||||
is
|
||||
}
|
||||
}
|
||||
|
||||
const vueExt = [ '.vue' ];
|
||||
const scriptExt = [ '.js', '.jsx', '.ts', '.tsx', '.vue' ];
|
||||
const styleExt = [ '.css', '.scss', '.module.scss', '.sass', '.module.sass' ];
|
||||
|
||||
const isOfExt = ({ extensions, filename, query }) =>
|
||||
extensions.some(
|
||||
ext => filename?.endsWith(ext) || query?.[ `lang${ ext }` ] !== void 0
|
||||
);
|
||||
|
||||
const defaultOptions = {
|
||||
runMode: 'web-client',
|
||||
autoImportComponentCase: 'kebab',
|
||||
sassVariables: true,
|
||||
devTreeshaking: false
|
||||
};
|
||||
|
||||
function getConfigPlugin (opts) {
|
||||
return {
|
||||
name: 'vite:quasar:vite-conf',
|
||||
|
||||
configResolved (viteConf) {
|
||||
const vueCfg = viteConf.plugins.find(entry => entry.name === 'vite:vue');
|
||||
|
||||
if (vueCfg === void 0) {
|
||||
console.error('\n\n[Quasar] Error: In your Vite config file, please add the Quasar plugin ** after ** the Vue one\n\n');
|
||||
process.exit(1);
|
||||
}
|
||||
},
|
||||
|
||||
config (viteConf, { mode }) {
|
||||
return getViteConfig(opts.runMode, mode, viteConf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getScssTransformsPlugin (opts) {
|
||||
const sassVariables = typeof opts.sassVariables === 'string'
|
||||
? vite.normalizePath(opts.sassVariables)
|
||||
: opts.sassVariables;
|
||||
|
||||
const scssTransform = createScssTransform('scss', sassVariables);
|
||||
const sassTransform = createScssTransform('sass', sassVariables);
|
||||
const scssExt = [ '.scss', '.module.scss' ];
|
||||
const sassExt = [ '.sass', '.module.sass' ];
|
||||
|
||||
return {
|
||||
name: 'vite:quasar:scss',
|
||||
|
||||
enforce: 'pre',
|
||||
|
||||
transform (src, id) {
|
||||
const { is } = parseViteRequest(id);
|
||||
|
||||
if (is.style(scssExt) === true) {
|
||||
return {
|
||||
code: scssTransform(src),
|
||||
map: null
|
||||
}
|
||||
}
|
||||
|
||||
if (is.style(sassExt) === true) {
|
||||
return {
|
||||
code: sassTransform(src),
|
||||
map: null
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getScriptTransformsPlugin (opts) {
|
||||
let useTreeshaking = true;
|
||||
|
||||
return {
|
||||
name: 'vite:quasar:script',
|
||||
|
||||
configResolved (resolvedConfig) {
|
||||
if (opts.devTreeshaking === false && resolvedConfig.mode !== 'production') {
|
||||
useTreeshaking = false;
|
||||
}
|
||||
},
|
||||
|
||||
transform (src, id) {
|
||||
const { is } = parseViteRequest(id);
|
||||
|
||||
if (is.template() === true) {
|
||||
return {
|
||||
code: vueTransform(src, opts.autoImportComponentCase, useTreeshaking),
|
||||
map: null // provide source map if available
|
||||
}
|
||||
}
|
||||
|
||||
if (useTreeshaking === true && is.script() === true) {
|
||||
return {
|
||||
code: mapQuasarImports(src),
|
||||
map: null // provide source map if available
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function plugin (userOpts = {}) {
|
||||
const opts = {
|
||||
...defaultOptions,
|
||||
...userOpts
|
||||
};
|
||||
|
||||
const plugins = [
|
||||
getConfigPlugin(opts)
|
||||
];
|
||||
|
||||
if (opts.sassVariables) {
|
||||
plugins.push(
|
||||
getScssTransformsPlugin(opts)
|
||||
);
|
||||
}
|
||||
|
||||
if (opts.runMode !== 'ssr-server') {
|
||||
plugins.push(
|
||||
getScriptTransformsPlugin(opts)
|
||||
);
|
||||
}
|
||||
|
||||
return plugins
|
||||
}
|
||||
|
||||
const transformAssetUrls = JSON.parse(
|
||||
node_fs.readFileSync(node_path.join(quasarPath, 'dist/transforms/loader-asset-urls.json'), 'utf-8')
|
||||
);
|
||||
|
||||
exports.quasar = plugin;
|
||||
exports.transformAssetUrls = transformAssetUrls;
|
||||
64
node_modules/@quasar/vite-plugin/index.d.ts
generated
vendored
Normal file
64
node_modules/@quasar/vite-plugin/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
// @ts-ignore
|
||||
/// <reference types="@quasar/vite-plugin" />
|
||||
|
||||
import type { Plugin } from "vite";
|
||||
|
||||
export interface QuasarPluginOpts {
|
||||
/**
|
||||
* Auto import - how to detect components in your vue files
|
||||
* "kebab": q-carousel q-page
|
||||
* "pascal": QCarousel QPage
|
||||
* "combined": q-carousel QPage
|
||||
*/
|
||||
autoImportComponentCase?: "kebab" | "pascal" | "combined";
|
||||
|
||||
/**
|
||||
* Would you like to use Quasar's SCSS/Sass variables?
|
||||
* true
|
||||
* --> yes, all my vue files will be able to use $primary etc
|
||||
* false
|
||||
* --> no, don't make the variables available in vue files
|
||||
* "src/my-variables.sass"
|
||||
* --> yes, and I'd also like to customize those variables
|
||||
*/
|
||||
sassVariables?: string | boolean;
|
||||
|
||||
/**
|
||||
* How will Quasar be used? In a:
|
||||
* "web-client" (default)
|
||||
* "ssr-server" (used by @quasar/app-vite)
|
||||
* "ssr-client" (used by @quasar/app-vite)
|
||||
*/
|
||||
runMode?: "web-client" | "ssr-client" | "ssr-server";
|
||||
|
||||
/**
|
||||
* Treeshake Quasar's UI on dev too?
|
||||
* Recommended to leave this as false for performance reasons.
|
||||
* @default false
|
||||
*/
|
||||
devTreeshaking?: boolean;
|
||||
}
|
||||
|
||||
export function quasar(opts?: QuasarPluginOpts): Plugin;
|
||||
|
||||
// `TransformAssetUrls` copy of https://github.com/vuejs/vue-next/blob/2c221fcd497d1541e667892ed908631df7e4a745/packages/compiler-sfc/src/compileTemplate.ts#L67
|
||||
export interface AssetURLTagConfig {
|
||||
[name: string]: string[];
|
||||
}
|
||||
|
||||
export interface AssetURLOptions {
|
||||
/**
|
||||
* If base is provided, instead of transforming relative asset urls into
|
||||
* imports, they will be directly rewritten to absolute urls.
|
||||
*/
|
||||
base?: string | null;
|
||||
/**
|
||||
* If true, also processes absolute urls.
|
||||
*/
|
||||
includeAbsolute?: boolean;
|
||||
tags?: AssetURLTagConfig;
|
||||
}
|
||||
|
||||
export type TransformAssetUrls = AssetURLOptions | AssetURLTagConfig | boolean;
|
||||
|
||||
export const transformAssetUrls: AssetURLOptions;
|
||||
80
node_modules/@quasar/vite-plugin/package.json
generated
vendored
Normal file
80
node_modules/@quasar/vite-plugin/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
"name": "@quasar/vite-plugin",
|
||||
"version": "1.4.1",
|
||||
"description": "Vite plugin for Quasar Framework",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./src/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./*": "./*"
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"build": "rm -rf ./dist/ && rollup --config rollup.config.js",
|
||||
"lint": "eslint --fix --ext .js,.vue --ignore-path .gitignore .",
|
||||
"test": "yarn test:unit:ci && yarn test:e2e:ci",
|
||||
"test:unit:dev": "vitest",
|
||||
"test:unit:ci": "vitest run",
|
||||
"test:e2e:start:dev": "cd ./playground && yarn dev --port 9000",
|
||||
"test:e2e:start:serve": "cd ./playground && yarn start --port 9000",
|
||||
"test:e2e:dev": "start-test \"yarn test:e2e:start:dev\" http-get://localhost:9000 \"yarn cypress open --e2e\"",
|
||||
"test:e2e:ci": "start-test \"yarn test:e2e:start:serve\" http-get://localhost:9000 \"yarn cypress run --e2e\""
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"vite-plugin",
|
||||
"quasar",
|
||||
"vite",
|
||||
"vue",
|
||||
"vuejs"
|
||||
],
|
||||
"author": {
|
||||
"name": "Razvan Stoenescu",
|
||||
"email": "razvan.stoenescu@gmail.com",
|
||||
"url": "https://github.com/quasarframework"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/quasarframework/quasar"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cypress": "^12.10.0",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
"eslint-plugin-import": "^2.19.1",
|
||||
"eslint-plugin-n": "^16.0.0",
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
"eslint-plugin-vue": "^9.14.1",
|
||||
"quasar": "^2.11.10",
|
||||
"rollup": "^2.58.0",
|
||||
"start-server-and-test": "^2.0.0",
|
||||
"typescript": "^5.0.4",
|
||||
"vitest": "^0.30.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vitejs/plugin-vue": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
||||
"quasar": "^2.8.0",
|
||||
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
||||
"vue": "^3.0.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/quasarframework/quasar/issues",
|
||||
"homepage": "https://quasar.dev",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://donate.quasar.dev"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
15
node_modules/@quasar/vite-plugin/src/index.js
generated
vendored
Executable file
15
node_modules/@quasar/vite-plugin/src/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
|
||||
import { quasarPath } from './quasar-path.js'
|
||||
import quasar from './plugin.js'
|
||||
|
||||
const transformAssetUrls = JSON.parse(
|
||||
readFileSync(join(quasarPath, 'dist/transforms/loader-asset-urls.json'), 'utf-8')
|
||||
)
|
||||
|
||||
export {
|
||||
quasar,
|
||||
transformAssetUrls
|
||||
}
|
||||
74
node_modules/@quasar/vite-plugin/src/js-transform.js
generated
vendored
Executable file
74
node_modules/@quasar/vite-plugin/src/js-transform.js
generated
vendored
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
|
||||
import importTransformation from 'quasar/dist/transforms/import-transformation.js'
|
||||
|
||||
const importQuasarRegex = /import\s*\{([\w,\s]+)\}\s*from\s*(['"])quasar\2;?/g
|
||||
|
||||
/**
|
||||
* Transforms JS code where importing from 'quasar' package
|
||||
* Example:
|
||||
* import { QBtn } from 'quasar'
|
||||
* -> import QBtn from 'quasar/src/components/QBtn.js'
|
||||
*/
|
||||
export function mapQuasarImports (code, importMap = {}) {
|
||||
return code.replace(
|
||||
importQuasarRegex,
|
||||
(_, match) => match
|
||||
.split(',')
|
||||
.map(identifier => {
|
||||
const data = identifier.split(' as ')
|
||||
const importName = data[ 0 ].trim()
|
||||
|
||||
// might be an empty entry like below
|
||||
// (notice useQuasar is followed by a comma)
|
||||
// import { QTable, useQuasar, } from 'quasar'
|
||||
if (importName === '') {
|
||||
return ''
|
||||
}
|
||||
|
||||
const importAs = data[ 1 ] !== void 0
|
||||
? data[ 1 ].trim()
|
||||
: importName
|
||||
|
||||
importMap[ importName ] = importAs
|
||||
return `import ${ importAs } from '${ importTransformation(importName) }';`
|
||||
})
|
||||
.join('')
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms JS code where importing from 'quasar' package
|
||||
* Example:
|
||||
* import { QBtn } from 'quasar'
|
||||
* -> add to importMap & importList & remove original import statement
|
||||
* (removing original is required so that the end file will have
|
||||
* only one import from Quasar statement)
|
||||
*/
|
||||
export function removeQuasarImports (code, importMap, importSet, reverseMap) {
|
||||
return code.replace(
|
||||
importQuasarRegex,
|
||||
(_, match) => {
|
||||
match.split(',').forEach(identifier => {
|
||||
const data = identifier.split(' as ')
|
||||
const importName = data[ 0 ].trim()
|
||||
|
||||
// might be an empty entry like below
|
||||
// (notice useQuasar is followed by a comma)
|
||||
// import { QTable, useQuasar, } from 'quasar'
|
||||
if (importName !== '') {
|
||||
const importAs = data[ 1 ] !== void 0
|
||||
? data[ 1 ].trim()
|
||||
: importName
|
||||
|
||||
importSet.add(importName + (importAs !== importName ? ` as ${ importAs }` : ''))
|
||||
importMap[ importName ] = importAs
|
||||
reverseMap[ importName.replace(/-/g, '_') ] = importAs
|
||||
}
|
||||
})
|
||||
|
||||
// we registered the original import and we
|
||||
// remove this one to avoid duplicate imports from Quasar
|
||||
return ''
|
||||
}
|
||||
)
|
||||
}
|
||||
130
node_modules/@quasar/vite-plugin/src/plugin.js
generated
vendored
Normal file
130
node_modules/@quasar/vite-plugin/src/plugin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
|
||||
import { normalizePath } from 'vite'
|
||||
|
||||
import { getViteConfig } from './vite-config.js'
|
||||
import { vueTransform } from './vue-transform.js'
|
||||
import { createScssTransform } from './scss-transform.js'
|
||||
import { parseViteRequest } from './query.js'
|
||||
import { mapQuasarImports } from './js-transform.js'
|
||||
|
||||
const defaultOptions = {
|
||||
runMode: 'web-client',
|
||||
autoImportComponentCase: 'kebab',
|
||||
sassVariables: true,
|
||||
devTreeshaking: false
|
||||
}
|
||||
|
||||
function getConfigPlugin (opts) {
|
||||
return {
|
||||
name: 'vite:quasar:vite-conf',
|
||||
|
||||
configResolved (viteConf) {
|
||||
const vueCfg = viteConf.plugins.find(entry => entry.name === 'vite:vue')
|
||||
|
||||
if (vueCfg === void 0) {
|
||||
console.error('\n\n[Quasar] Error: In your Vite config file, please add the Quasar plugin ** after ** the Vue one\n\n')
|
||||
process.exit(1)
|
||||
}
|
||||
},
|
||||
|
||||
config (viteConf, { mode }) {
|
||||
return getViteConfig(opts.runMode, mode, viteConf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getScssTransformsPlugin (opts) {
|
||||
const sassVariables = typeof opts.sassVariables === 'string'
|
||||
? normalizePath(opts.sassVariables)
|
||||
: opts.sassVariables
|
||||
|
||||
const scssTransform = createScssTransform('scss', sassVariables)
|
||||
const sassTransform = createScssTransform('sass', sassVariables)
|
||||
const scssExt = [ '.scss', '.module.scss' ]
|
||||
const sassExt = [ '.sass', '.module.sass' ]
|
||||
|
||||
return {
|
||||
name: 'vite:quasar:scss',
|
||||
|
||||
enforce: 'pre',
|
||||
|
||||
transform (src, id) {
|
||||
const { is } = parseViteRequest(id)
|
||||
|
||||
if (is.style(scssExt) === true) {
|
||||
return {
|
||||
code: scssTransform(src),
|
||||
map: null
|
||||
}
|
||||
}
|
||||
|
||||
if (is.style(sassExt) === true) {
|
||||
return {
|
||||
code: sassTransform(src),
|
||||
map: null
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getScriptTransformsPlugin (opts) {
|
||||
let useTreeshaking = true
|
||||
|
||||
return {
|
||||
name: 'vite:quasar:script',
|
||||
|
||||
configResolved (resolvedConfig) {
|
||||
if (opts.devTreeshaking === false && resolvedConfig.mode !== 'production') {
|
||||
useTreeshaking = false
|
||||
}
|
||||
},
|
||||
|
||||
transform (src, id) {
|
||||
const { is } = parseViteRequest(id)
|
||||
|
||||
if (is.template() === true) {
|
||||
return {
|
||||
code: vueTransform(src, opts.autoImportComponentCase, useTreeshaking),
|
||||
map: null // provide source map if available
|
||||
}
|
||||
}
|
||||
|
||||
if (useTreeshaking === true && is.script() === true) {
|
||||
return {
|
||||
code: mapQuasarImports(src),
|
||||
map: null // provide source map if available
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function (userOpts = {}) {
|
||||
const opts = {
|
||||
...defaultOptions,
|
||||
...userOpts
|
||||
}
|
||||
|
||||
const plugins = [
|
||||
getConfigPlugin(opts)
|
||||
]
|
||||
|
||||
if (opts.sassVariables) {
|
||||
plugins.push(
|
||||
getScssTransformsPlugin(opts)
|
||||
)
|
||||
}
|
||||
|
||||
if (opts.runMode !== 'ssr-server') {
|
||||
plugins.push(
|
||||
getScriptTransformsPlugin(opts)
|
||||
)
|
||||
}
|
||||
|
||||
return plugins
|
||||
}
|
||||
7
node_modules/@quasar/vite-plugin/src/quasar-path.js
generated
vendored
Normal file
7
node_modules/@quasar/vite-plugin/src/quasar-path.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
import { createRequire } from 'node:module'
|
||||
import { dirname } from 'node:path'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
|
||||
export const quasarPath = dirname(require.resolve('quasar/package.json'))
|
||||
82
node_modules/@quasar/vite-plugin/src/query.js
generated
vendored
Normal file
82
node_modules/@quasar/vite-plugin/src/query.js
generated
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
|
||||
/**
|
||||
* @typedef {{
|
||||
* vue: () => boolean;
|
||||
* template: () => boolean;
|
||||
* script: (extensions?: string | string[]) => boolean;
|
||||
* style: (extensions?: string | string[]) => boolean;
|
||||
* }} ViteQueryIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see https://github.com/vitejs/vite/blob/364aae13f0826169e8b1c5db41ac6b5bb2756958/packages/plugin-vue/src/utils/query.ts - source of inspiration
|
||||
* @example
|
||||
* '/absolute/path/src/App.vue' // Can contain combined template&script -> template: true, script: true, style: false
|
||||
* '/absolute/path/src/App.vue?vue&type=script&lang.js' // Only contains script -> template: false, script: true, style: false
|
||||
* '/absolute/path/src/App.vue?vue&type=style&lang.sass' // Only contains style -> template: false, script: false, style: true
|
||||
* '/absolute/path/src/script.js' // Only contains script -> template: false, script: true, style: false
|
||||
* '/absolute/path/src/index.scss' // Only contains style -> template: false, script: false, style: true
|
||||
*
|
||||
* @param {string} id
|
||||
* @returns {{ filename: string; query: { [key: string]: string; }; is: ViteQueryIs }}
|
||||
*/
|
||||
export function parseViteRequest (id) {
|
||||
const [ filename, rawQuery ] = id.split('?', 2)
|
||||
const query = Object.fromEntries(new URLSearchParams(rawQuery))
|
||||
|
||||
const is = query.raw !== void 0
|
||||
? {
|
||||
// if it's a ?raw request, then don't touch it at all
|
||||
vue: () => false,
|
||||
template: () => false,
|
||||
script: () => false,
|
||||
style: () => false
|
||||
}
|
||||
: (
|
||||
query.vue !== void 0 // is vue query?
|
||||
? {
|
||||
// Almost all code might get merged into a single request with no 'type' (App.vue?vue)
|
||||
// or stay with their original 'type's (App.vue?vue&type=script&lang.ts)
|
||||
vue: () => true,
|
||||
|
||||
template: () => (
|
||||
query.type === void 0
|
||||
|| query.type === 'template'
|
||||
// On prod, TS code turns into a separate 'script' request.
|
||||
// See: https://github.com/vitejs/vite/pull/7909
|
||||
|| (query.type === 'script' && (query[ 'lang.ts' ] !== void 0 || query[ 'lang.tsx' ] !== void 0))
|
||||
),
|
||||
|
||||
script: (extensions = scriptExt) => (
|
||||
(query.type === void 0 || query.type === 'script')
|
||||
&& isOfExt({ query, extensions }) === true
|
||||
),
|
||||
|
||||
style: (extensions = styleExt) => (
|
||||
query.type === 'style'
|
||||
&& isOfExt({ query, extensions }) === true
|
||||
)
|
||||
}
|
||||
: {
|
||||
vue: () => isOfExt({ extensions: vueExt, filename }),
|
||||
template: () => isOfExt({ filename, extensions: vueExt }),
|
||||
script: (extensions = scriptExt) => isOfExt({ filename, extensions }),
|
||||
style: (extensions = styleExt) => isOfExt({ filename, extensions })
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
filename,
|
||||
query,
|
||||
is
|
||||
}
|
||||
}
|
||||
|
||||
const vueExt = [ '.vue' ]
|
||||
const scriptExt = [ '.js', '.jsx', '.ts', '.tsx', '.vue' ]
|
||||
const styleExt = [ '.css', '.scss', '.module.scss', '.sass', '.module.sass' ]
|
||||
|
||||
const isOfExt = ({ extensions, filename, query }) =>
|
||||
extensions.some(
|
||||
ext => filename?.endsWith(ext) || query?.[ `lang${ ext }` ] !== void 0
|
||||
)
|
||||
32
node_modules/@quasar/vite-plugin/src/scss-transform.js
generated
vendored
Normal file
32
node_modules/@quasar/vite-plugin/src/scss-transform.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
export function createScssTransform (fileExtension, sassVariables) {
|
||||
const sassImportCode = [ '@import \'quasar/src/css/variables.sass\'', '' ]
|
||||
|
||||
if (typeof sassVariables === 'string') {
|
||||
sassImportCode.unshift(`@import '${ sassVariables }'`)
|
||||
}
|
||||
|
||||
const prefix = fileExtension === 'sass'
|
||||
? sassImportCode.join('\n')
|
||||
: sassImportCode.join(';\n')
|
||||
|
||||
return content => {
|
||||
const useIndex = Math.max(
|
||||
content.lastIndexOf('@use '),
|
||||
content.lastIndexOf('@forward ')
|
||||
)
|
||||
|
||||
if (useIndex === -1) {
|
||||
return prefix + content
|
||||
}
|
||||
|
||||
const newLineIndex = content.indexOf('\n', useIndex)
|
||||
|
||||
if (newLineIndex !== -1) {
|
||||
const index = newLineIndex + 1
|
||||
return content.substring(0, index) + prefix + content.substring(index)
|
||||
}
|
||||
|
||||
return content + '\n' + prefix
|
||||
}
|
||||
}
|
||||
58
node_modules/@quasar/vite-plugin/src/vite-config.js
generated
vendored
Normal file
58
node_modules/@quasar/vite-plugin/src/vite-config.js
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
|
||||
import { quasarPath } from './quasar-path.js'
|
||||
|
||||
const { version } = JSON.parse(
|
||||
readFileSync(join(quasarPath, 'package.json'), 'utf-8')
|
||||
)
|
||||
|
||||
export function getViteConfig (runMode, viteMode, externalViteCfg) {
|
||||
const viteCfg = {
|
||||
define: {
|
||||
__QUASAR_VERSION__: `'${ version }'`,
|
||||
__QUASAR_SSR__: false,
|
||||
__QUASAR_SSR_SERVER__: false,
|
||||
__QUASAR_SSR_CLIENT__: false
|
||||
}
|
||||
}
|
||||
|
||||
// Set this to the default value only if it's not already set.
|
||||
// @quasar/app-vite configures this by itself when it needs it.
|
||||
if (!externalViteCfg.define || externalViteCfg.define.__QUASAR_SSR_PWA__ === void 0) {
|
||||
viteCfg.define.__QUASAR_SSR_PWA__ = false
|
||||
}
|
||||
|
||||
if (runMode === 'ssr-server') {
|
||||
Object.assign(viteCfg.define, {
|
||||
__QUASAR_SSR__: true,
|
||||
__QUASAR_SSR_SERVER__: true
|
||||
})
|
||||
}
|
||||
else {
|
||||
// Alias "quasar" package to its dev file (which has flags)
|
||||
// to reduce the number of HTTP requests while in DEV mode
|
||||
if (viteMode !== 'production') {
|
||||
viteCfg.resolve = {
|
||||
alias: [
|
||||
{ find: /^quasar$/, replacement: 'quasar/dist/quasar.esm.js' }
|
||||
]
|
||||
}
|
||||
}
|
||||
else {
|
||||
viteCfg.optimizeDeps = {
|
||||
exclude: [ 'quasar' ]
|
||||
}
|
||||
}
|
||||
|
||||
if (runMode === 'ssr-client') {
|
||||
Object.assign(viteCfg.define, {
|
||||
__QUASAR_SSR__: true,
|
||||
__QUASAR_SSR_CLIENT__: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return viteCfg
|
||||
}
|
||||
90
node_modules/@quasar/vite-plugin/src/vue-transform.js
generated
vendored
Executable file
90
node_modules/@quasar/vite-plugin/src/vue-transform.js
generated
vendored
Executable file
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
import { join } from 'node:path'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import importTransformation from 'quasar/dist/transforms/import-transformation.js'
|
||||
|
||||
import { mapQuasarImports, removeQuasarImports } from './js-transform.js'
|
||||
import { quasarPath } from './quasar-path.js'
|
||||
|
||||
const autoImportData = JSON.parse(
|
||||
readFileSync(join(quasarPath, 'dist/transforms/auto-import.json'), 'utf-8')
|
||||
)
|
||||
|
||||
const compRegex = {
|
||||
kebab: new RegExp(`_resolveComponent\\("${ autoImportData.regex.kebabComponents }"\\)`, 'g'),
|
||||
pascal: new RegExp(`_resolveComponent\\("${ autoImportData.regex.pascalComponents }"\\)`, 'g'),
|
||||
combined: new RegExp(`_resolveComponent\\("${ autoImportData.regex.components }"\\)`, 'g')
|
||||
}
|
||||
|
||||
const dirRegex = new RegExp(`_resolveDirective\\("${ autoImportData.regex.directives.replace(/v-/g, '') }"\\)`, 'g')
|
||||
const lengthSortFn = (a, b) => b.length - a.length
|
||||
|
||||
export function vueTransform (content, autoImportComponentCase, useTreeshaking) {
|
||||
const importSet = new Set()
|
||||
const importMap = {}
|
||||
|
||||
const compList = []
|
||||
const dirList = []
|
||||
|
||||
const reverseMap = {}
|
||||
const jsImportTransformed = useTreeshaking === true
|
||||
? mapQuasarImports(content, importMap)
|
||||
: removeQuasarImports(content, importMap, importSet, reverseMap)
|
||||
|
||||
let code = jsImportTransformed
|
||||
.replace(compRegex[ autoImportComponentCase ], (_, match) => {
|
||||
const name = autoImportData.importName[ match ]
|
||||
const reverseName = match.replace(/-/g, '_')
|
||||
|
||||
if (importMap[ name ] === void 0) {
|
||||
importSet.add(name)
|
||||
reverseMap[ reverseName ] = name
|
||||
}
|
||||
else {
|
||||
reverseMap[ reverseName ] = importMap[ name ]
|
||||
}
|
||||
|
||||
compList.push(reverseName)
|
||||
return ''
|
||||
})
|
||||
.replace(dirRegex, (_, match) => {
|
||||
const name = autoImportData.importName[ 'v-' + match ]
|
||||
const reverseName = match.replace(/-/g, '_')
|
||||
|
||||
if (importMap[ name ] === void 0) {
|
||||
importSet.add(name)
|
||||
reverseMap[ reverseName ] = name
|
||||
}
|
||||
else {
|
||||
reverseMap[ reverseName ] = importMap[ name ]
|
||||
}
|
||||
|
||||
dirList.push(reverseName)
|
||||
return ''
|
||||
})
|
||||
|
||||
if (compList.length !== 0) {
|
||||
const list = compList.sort(lengthSortFn).join('|')
|
||||
code = code
|
||||
.replace(new RegExp(`const _component_(${ list }) = `, 'g'), '')
|
||||
.replace(new RegExp(`_component_(${ list })`, 'g'), (_, match) => reverseMap[ match ])
|
||||
}
|
||||
|
||||
if (dirList.length !== 0) {
|
||||
const list = dirList.sort(lengthSortFn).join('|')
|
||||
code = code
|
||||
.replace(new RegExp(`const _directive_(${ list }) = `, 'g'), '')
|
||||
.replace(new RegExp(`_directive_(${ list })`, 'g'), (_, match) => reverseMap[ match ])
|
||||
}
|
||||
|
||||
if (importSet.size === 0) {
|
||||
return code
|
||||
}
|
||||
|
||||
const importList = [ ...importSet ]
|
||||
const codePrefix = useTreeshaking === true
|
||||
? importList.map(name => `import ${ name } from '${ importTransformation(name) }'`).join(';')
|
||||
: `import {${ importList.join(',') }} from 'quasar'`
|
||||
|
||||
return codePrefix + ';' + code
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue