Comments (14)
Hey again ๐ Thanks for your help The main problem I think is that since there are two files with the same, but different extensions, this plugin converts them to the same variable ๐
I've moved away from the
require
statements and am trying a solution withimports
, I'll lay down a repo where the issue can be replicated.
I think the latest version can solve the problem of same file name,different extensions,I just wrote some test code,the default variable will be turn into fileName_extension_default format.
from vite-plugin-require-transform.
//same path,different extension
const testCaseA = require("caseA.extA?aaa");
const testCaseB = require("caseA.extB?bbb").default;
console.log("caseA", testCaseA)
console.log("caseB", testCaseB)`
will be turn into:
import { default as _vite_plugin_require_transform_caseA_extB_bbb_default } from "caseA.extB?bbb";
import _vite_plugin_require_transform_caseA_extA_aaa from "caseA.extA?aaa";
//same path,different extension
const testCaseA = _vite_plugin_require_transform_caseA_extA_aaa;
const testCaseB = _vite_plugin_require_transform_caseA_extB_bbb_default;
console.log("caseA", testCaseA);
console.log("caseB", testCaseB);
from vite-plugin-require-transform.
Can you take a screenshot about the error? maybe the error is not about the extensions I think, it's about the format require(...).default, let's see what the real problem is and I'm glad to fix it
from vite-plugin-require-transform.
Hey ๐
Thanks for replying.
From what I've seen, this started to happen with .css
& .ttf
files with the same name, here's my case:
& here's the error
from vite-plugin-require-transform.
In the case of audiosprites, which require to have the same name across different formats, this is also a blocker:
Basically, if we could add an option to suffix the variables with the file format, I think it would solve the issue
from vite-plugin-require-transform.
checkout the newest version,with readme about case 3,it's supported now!
from vite-plugin-require-transform.
Hey ๐
Thanks for your switf action ๐
I gave it a try and now it seems to be losing the file extension when importing:
Relevant code:
EDIT: Just posting my config
requireTransform(
(fileRegex = /.ts$|.tsx$|.png$|.css$|.json$|.ttf$|.ac3$|.ogg$|.m4a$|.mp3$/),
(prefix = "vite_require_transform_"),
(importPathHandler = (requirePath) => {
return requirePath.replace(".", "_");
})
),
from vite-plugin-require-transform.
Thanks for your patient,I think this time would be fixed,just check the newest version again
from vite-plugin-require-transform.
Hey man ๐
Thanks again for comming up with a solution.
I gave it a shot and while it did indeed fixed the required errors, I now have the wrong file being loaded.
I'm still not 100% clear if this is something I'm doing wrong, but then again, I'm migrating from webpack, so I expected this to work almost out of the box ๐
I'll post here if I manage to get a handle on the transpiled files
from vite-plugin-require-transform.
I've tried to move the .default
to another part of the app, and I'm back to the first error.
Here's the relevant code:
ImagesHudShiftKeyFrames
is an empty enum
And my config:
defineConfig({
plugins: [
requireTransform(
(fileRegex = /.ts$|.tsx$|.png$|.css$|.json$|.ttf$|.ac3$|.ogg$|.m4a$|.mp3$/),
(prefix = "vite_require_transform_"),
(importPathHandler = (requirePath) => {
return requirePath.replace(".", "_");
})
),
],
...})
from vite-plugin-require-transform.
Thanks for your patitent again and I'm glad to solve the problem.I am not sure if it is the cause the problem of the plugin,Actually I can not understand the real problem that you propose this time,maybe you can provide a minimal repo link that can reproduce the problem you ran into.
from vite-plugin-require-transform.
Hey again ๐
Thanks for your help
The main problem I think is that since there are two files with the same, but different extensions, this plugin converts them to the same variable ๐
I've moved away from the require
statements and am trying a solution with imports
, I'll lay down a repo where the issue can be replicated.
from vite-plugin-require-transform.
Thanks for the help :)
from vite-plugin-require-transform.
Thanks for the help :)
you're welcome.It's my pleasure hahah to make sth to help anyone in the world,my friend
from vite-plugin-require-transform.
Related Issues (20)
- requireTransform is not a function HOT 5
- SyntaxError: Cannot use import statement outside a module HOT 2
- vue2.6.12 and use [email protected], vite build failed HOT 1
- [plugin:_vite_plugin_require_transform_] Unexpected token (1:39) - make sure this is an expression.
- "default" is not exported by "node_modules/react/cjs/react.development.js", imported by "node_modules/react/index.js".
- "default" is not exported by "node_modules/react/cjs/react.development.js", imported by "node_modules/react/index.js".
- why dist/index.d.ts is empty HOT 4
- ไธบไปไนvite-plugin-require-transform่ฟไนๅไผๆฅ้๏ผๆไน่งฃๅณ HOT 1
- The requested module '/config/env.ts' does not provide an export named 'default HOT 2
- 1.0.11 index.d.ts not packaged HOT 3
- ERROR [_vite_plugin_require_transform_] traverse is not a function HOT 26
- vite4+vue3+js ๆๅปบ้่ฏฏ HOT 1
- Vite2.9.9 + Vue2 +vite-plugin-require-transform: "^1.0.17" ็้กน็ฎไธญ๏ผnpm run build็ๆถๅๆฅ้Unexpected token (1:42) - make sure this is an expression. HOT 8
- `Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/luxon.js?v=df68325f' does not provide an export named 'default'`
- Sourcemap does not point at original `require` for newly added `import`
- ไธบๅฅๆ่ฟไธชไผๆฅ้ HOT 1
- Import statements are in reverse order HOT 2
- "What vite-plugin-require-transform actually do" in README is outdated
- Dynamic import strange bugs HOT 1
- 'default' is not exported by node_modules/axios/index.js, imported by src/utils/request.js HOT 1
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-require-transform.