Comments (10)
Use module
or mapping
:
autoImport({
components: [],
mapping: {
SomeLib: `import SomeLib from 'some-lib'`
}
})
from sveltekit-autoimport.
Do you have an example or docs for these features? I'm not sure how I would use that in my case.
from sveltekit-autoimport.
For example, I have a <Video v="XXXXXX"/>
component in my markdown. It comes from import {Video} from tecitheme/components/Video.svelte'
If I add that import line to the script in markdown the component works as expected.
from sveltekit-autoimport.
Yeah there are examples at the bottom of readme file.
autoImport({
/* .. */
mapping: {
Video: `import {Video} from 'tecitheme/components/Video.svelte'`
}
})
from sveltekit-autoimport.
It means how/where to import the Video
component. They can be component, variable, or a function:
autoImport({
/* .. */
mapping: {
VideoX: `import { Video as VideoX } from 'tecitheme/components/Video.svelte'`,
T: `import T from './lib/language/get-text.js'`,
/* I wouldn't suggest this */
GLOBAL_VAR: `const GLOBAL_VAR = 'hello world';`,
}
})
from sveltekit-autoimport.
Ok, instead of mapping all of the components individually, would it be possible to add the node module to the "components" array and have them all imported automatically? That's how it works if they are in a local folder, like ./src/lib/components
.
from sveltekit-autoimport.
I suggest import them manually and explicitly for the third-party components. There's also a module
option for selecting multiple items for a module.
autoImport({
/* .. */
module: {
'some-component-lib': ['Video', 'Caption']
}
})
Which means:
import { Video, Caption } from 'some-component-lib'
from sveltekit-autoimport.
Ok this works well for me. Thank you.
from sveltekit-autoimport.
autoImport({ /* .. */ module: { 'some-component-lib': ['Video', 'Caption'] } })
How would you do this in my case where the components are in the 'components' subdirectory of the theme?
BTW, the following code works for me now.
mapping: {
Video: `import Video from 'tecitheme/components/Video.svelte'`
}
from sveltekit-autoimport.
The package tecitheme
is missing an entry file like index.js
for exporting all packages outside. So you have to import them one by one
from sveltekit-autoimport.
Related Issues (20)
- Should it better be called "sveltekit-autoimport"?
- Possible support for .js-files by wildcard? HOT 6
- Import Fails with SCSS nesting HOT 6
- TS let statement breaking import HOT 3
- Broken for sveltekit version >= 1.0.0-next.346
- Doesn't auto-import for svelte auto-subscriptions
- Doesn't auto-import for Object indented Components
- Support for auto-import inside <script context="module">
- Error: Failed to parse source for import analysis because the content contains invalid JS syntax. HOT 5
- Make it compatible with SK version >= 1.0.0-next.359 HOT 2
- Sveltekit: missing-declaration HOT 6
- VSCode support HOT 8
- Typescript Support
- Error with auto-import and mdsvex Layout component.
- Is it possible to auto import 'svelte/transition'? HOT 6
- How can I make this work with MDsveX? HOT 34
- Nested Components HOT 2
- Import Broken When lang="ts HOT 9
- Importing '$app/stores' : ['page'] brings about crbug 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 sveltekit-autoimport.