Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

dynamic import support #990

Closed
NickIliev opened this issue Jul 16, 2019 · 5 comments
Closed

dynamic import support #990

NickIliev opened this issue Jul 16, 2019 · 5 comments

Comments

@NickIliev
Copy link
Contributor

@Serge-SDL commented on Tue Jul 16 2019

Hi,

I need to use some dynamic import in my app (importing js module from http or local device file), but it doesn't work.

I tried :
import(/* webpackIgnore: true */ file.path) -> got the error "Not supported"

and
System.import(file.path) -> got the error "Cannot find module '/path/to/file'" even if the file exists.

Is this situation expected? Is there an other way?
thanks for your help!

@Serge-SDL
Copy link

Hi @NickIliev ,
I think you can close this issue, I already opened a other on this nativescript-dev-webpack topic.
thanks

@sis0k0
Copy link
Contributor

sis0k0 commented Jul 16, 2019

Hi @Serge-SDL, could you please verify that the file is actually present in the built application? The webpack compilation includes only files that are explicitly required in the source code or included by some webpack plugin. An easy way to copy static assets is by using the CopyWebpackPlugin:

new CopyWebpackPlugin([
{ from: { glob: "fonts/**" } },
{ from: { glob: "**/*.jpg" } },
{ from: { glob: "**/*.png" } },
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),

@Serge-SDL
Copy link

@sis0k0
Thank you for your quick answer!
Actually for my test I create a file at runtime and try to import this file so I'm sure the file exists.
more details here: #989

@NickIliev
Copy link
Contributor Author

Closing as a duplicate to #990 - please continue the discussion in the linked issue.

@rynop
Copy link

rynop commented Jul 19, 2019

I think ^ meant #989 not 990

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants