dynamic-import Questions

6

Solved

I want to load a component dynamically based on the route. I'm trying to make a single page which can load any individual component for testing purposes. However whenever I try to do import(path) i...
Jegger asked 16/7, 2020 at 20:11

2

Solved

I am trying to load a single ESM module in my TypeScript CJS project. All examples I find are for JavaScript. // example.ts export const example = async () => { const module = await import(&quo...

1

I want to to dynamically import several mdx files into a react component, e.g. I have a page that requires different mdx files depending on the selected language, so only one specific file is loade...
Ingurgitate asked 15/11, 2022 at 17:50

3

Solved

I wish to dynamically import a module in Python (3.7), whereby the module's code is defined within a string. Below is a working example that uses the imp module, which is deprecated in favour of i...
Loutitia asked 29/4, 2019 at 14:14

8

I'm building a discord.js Discord bot. Now for some reason, discord.js doesn't work with ESM modules (a totally separate issue), so my bot app uses CommonJS modules. Now I have another project on m...
Frederick asked 12/12, 2020 at 13:22

3

Solved

I Just created a react app. The npm start seems to work fine but npm run build is constantly failing. I need to run npm run build to deploy it on some website. Already gone through all posts relate...
Dissertate asked 20/10, 2022 at 16:27

5

Solved

So I have to load a value from a configuration json file in my Angular 8 app. In the beginning I was loading it statically and so when the js was minified - the unset value from the json was read...
Pendulous asked 10/4, 2020 at 6:24

3

Solved

I'm currently using React 16 with Suspense and Lazy to code-split my codebase. Although I would like to preload components. In my example below I got two routes. Is there a way to preload Demo as...
Yogurt asked 11/11, 2018 at 20:21

3

I am creating an icon component with unplugin-icon and in usual case i can import for example //script import IconCopy from '~icons/prime/copy' //template <IconCopy/> it works but it feels u...
Vaginal asked 21/8, 2022 at 8:46

0

I have a [...pageId].tsx file in the /pages directory. In getServerSideProps, the page will check a CMS, and find a list of components to render. I want to load those components serverside, then re...

2

Solved

I have a React+vite app for which I'm writing test to cover the front-end routing redirection logic at application startup. Routing is handled by react-router v6, and all components associated with...
Lysippus asked 24/8, 2022 at 14:46

0

I am using Parcel to bundle my Javascript files. Everything works fine when using the localhost server to test out the build, however in production it doesn't like dynamic imports. Here is the code...
Locket asked 8/7, 2022 at 17:20

3

Solved

I want to dynamically import components without importing a specific component. I want to set the component name with a variable, received from the store: <script lang="ts"> // SVE...
Sonasonant asked 23/9, 2021 at 7:14

3

I'm building a next.js application and would like to load Google Tag Manager (GTM) only AFTER the entire page is loaded. The goal behind this is to improve the website performance. Has anyone figur...

4

Solved

I have a trusted remote server that stores many custom Python modules. I can fetch them via HTTP (e.g. using urllib2.urlopen) as text/plain, but I cannot save the fetched module code to the local h...
Cheerly asked 26/9, 2010 at 19:57

1

Solved

I have a navbar npm package that I import into other projects. It dynamically imports FontAwesome icons based on a JSON config file loaded from a web server at runtime. When I build the navbar pack...
Alethiaaletta asked 14/8, 2019 at 14:8

2

Solved

I have the following example running without the JS having a bundler on top of it. // index.js ;(async () => { const mod = await import('/index.json') console.log(mod) })() { "file": "ind...
Voltaic asked 9/2, 2020 at 19:11

2

Solved

I have only been programming with react for a short time and I don't know if there is a more efficient way to perform this task. I have a series of files that correspond to some svg files. An examp...

4

Have seen a couple of answers online but there are no clear explanations and the solutions don't work. So this is what I am trying to do: I have a folder of MANY images (thousands) - currently it...
Bleb asked 4/6, 2020 at 10:7

0

I have looked through many similar questions on SO, and haven't found a clear answer. I'm writing an npm CLI tool which is supposed to dynamically import a specified module and run some operations ...

2

Solved

So I have been struggling with how to test dynamic imports generally and in this case, especially in jest, I have been reading a lot on the internet but did not find anything concrete, so I thought...
Rawley asked 14/9, 2020 at 22:58

1

I am creating shared modules that contain dynamic imports for code splitting. I have code like: import('./moduleA').then(/* do stuff */) However babel compiles this to a deferred require which sto...
Strapped asked 24/8, 2020 at 14:54

0

I am exporting a React component as a library via Webpack. Within that library, I have several React.lazy() calls performing dynamic imports: library.tsx: import React from 'react'; const Compone...
Toner asked 6/6, 2020 at 23:30

1

How does the bundling happens when you use something like this: const module = import(`folder1/${someExpression}`); I mean, I do understand when you pass a plain string to it, but how does webpack ...
Horton asked 25/5, 2020 at 3:32

1

Solved

I am working on Single Page Architecture (SPA) Web application. I am have implemented functionality to dynamically load different pages of application. This is what my spa.js looks like var spa =...
Gaucherie asked 19/5, 2020 at 13:19

© 2022 - 2024 — McMap. All rights reserved.