Comments (12)
Now, vite-plugin-dynaimc-import
is available.
from vite-plugin-dynamic-import.
I think I might need a Windows PC to reproduce the BUG 😅
from vite-plugin-dynamic-import.
I managed to fix it by adding the normalizePath
to the following two paths
I have created the pull request #14
from vite-plugin-dynamic-import.
You can provide complete configuration?
from vite-plugin-dynamic-import.
In dynamic-import-to-glob I make this change for testing:
if ((!glob.startsWith('./') && !glob.startsWith('../')) && (!glob.startsWith('.\\') && !glob.startsWith('..\\'))) {
The problem is in Windows path is like ..\..\..\components\etc...
from vite-plugin-dynamic-import.
You can try wrapping a normalizePath()
import { normalizePath } from 'vite'
resolve: { alias: { '@': normalizePath(resolve(__dirname, './src')), }, },
from vite-plugin-dynamic-import.
Is getting the same error
from vite-plugin-dynamic-import.
It also happens to me with Linux debian.
[vite-plugin-dynamic-import] invalid import "import(`@/${comp}`)". Variable bare imports are not supported, imports must start with ./ in the static part of the import. For example: i
mport(`./foo/${bar}.js`).
vite.config.js:
import {createVuePlugin} from "vite-plugin-vue2";
import viteCompression from "vite-plugin-compression";
import dynamicImport from "vite-plugin-dynamic-import";
import {defineConfig, normalizePath} from "vite";
import path from "path";
import fs from "fs";
const HOST = "0.0.0.0";
import JSON5 from "json5";
import YAML from "yaml";
const baseConfig = YAML.parse(fs.readFileSync("/etc/default/itdfw.yaml", {encoding: "utf8"}));
const {config: configDir, fileType} = baseConfig;
const configPath = path.resolve(configDir, `config.${fileType}`);
const configFile = fs.readFileSync(configPath, {encoding: "utf8"});
let configObj;
switch (fileType) {
case "yaml":
configObj = YAML.parse(configFile);
break;
case "json":
configObj = JSON.parse(configFile);
break;
case "json5":
configObj = JSON5.parse(configFile);
break;
case "js":
configObj = require(configPath);
break;
default:
throw new Error("fileType unknown, pleas check fileType key in /etc/default/itdfw.yaml");
}
let itdConfig = {};
try {
itdConfig = require(path.resolve(process.cwd(), "../.itdfw.js"));
} catch (e) {
console.warn(".itdfw.js doesn't exist");
}
let protocol;
switch (configObj.Protocol) {
case "H2":
case "SPDY":
case "HTTP2":
case "HTTPS":
protocol = "https";
break;
case "HTTP":
default:
protocol = "http";
}
process.env.VUE_APP_PROTOCOL = protocol;
const proxy = `${protocol}://${itdConfig.devHost || process.env.VUE_APP_HOST}`;
console.log("proxy:", proxy);
const {DocumentRoot} = baseConfig;
const config = defineConfig({
base: "./",
server: {
host: HOST,
proxy: {
"/APP": {
target: proxy,
changeOrigin: true
}
}
},
resolve: {
alias: [
{
find: "@/",
replacement: normalizePath(path.resolve(__dirname, "src"))
},
{
find: "itdfw/",
replacement: path.resolve(__dirname, "src")
},
{
find: /^ITDFW$/,
replacement: path.resolve(__dirname)
},
{
find: "default/",
replacement: path.resolve(DocumentRoot, "DEFAULT/vue/src")
}
]
},
plugins: [
dynamicImport(),
createVuePlugin({
template: {
compilerOptions: {
isCustomElement: tag => tag.includes("itd-wc")
}
}
}),
viteCompression()
],
build: {
outDir: "../html"
}
});
export default config;
node: 16.15.1
vite: 2.9.13
rollup: 2.75.6
vite-plugin-dynamic-import: 0.9.9
from vite-plugin-dynamic-import.
@chumager thanks for your feedback. Can you provide a minimize Demo?
from vite-plugin-dynamic-import.
@caoxiemeihao A new version will be generated??
from vite-plugin-dynamic-import.
@GKhelio coming soon...
from vite-plugin-dynamic-import.
@caoxiemeihao thx!!
from vite-plugin-dynamic-import.
Related Issues (20)
- Bare imports do not work in monorepos HOT 8
- Cannot find module 'vite-plugin-utils' or its corresponding type declarations. HOT 2
- Build error when using the plugin in Vite.config HOT 1
- How can I import from some package?
- when this method in node_modules HOT 8
- Internal server error: Cannot use 'import.meta' outside a module HOT 3
- when i use node_modules error will occur when starting HOT 3
- Source Maps and Line Numbers are not correct HOT 1
- Please add a LICENSE if you are okay with people using this plugin HOT 1
- Not working in Vue project HOT 1
- `// [vite-plugin-dynamic-import] runtime -S-` header missing in compiled source HOT 3
- Massive import size HOT 2
- [vite-plugin-dynamic-import] Generated runtime code has redundant judgment rules in some cases HOT 1
- The above dynamic import cannot be analyzed by Vite. HOT 5
- Dynamic import not working Windows HOT 1
- Failed to parse vite-plugin-federation HOT 1
- Imports don't work within defineAsyncComponent() in Vue 2/3 HOT 2
- [Feature Request] Import map support HOT 5
- dynamic import not include subfolder HOT 1
- re Disable dynamic import detection for one line or for whole project HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite-plugin-dynamic-import.