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

dynamic import issue with webpack #989

Closed
@Serge-SDL

Description

@Serge-SDL

Hi,

I need to use dynamic import in my project to perform semthing like this (load a module js file stored in app documents):

        const file = knownFolders.documents().getFile('test.js');
        const jsCode = `
            module.exports = { test: function(str) { return 'x' + str; } }
        `;
        file.writeTextSync(jsCode);
    
        import(/* webpackIgnore: true */ file.path)
            .then((res) => {
                console.log('imported file res', res, res.test('y'));
            }).catch((err) => {
                console.log('error', err);
            });

this code work fine with useLegacyWorkflow: true, but failed with useLegacyWorkflow: false
-> I got the error: "Not supported" on android
-> I got the error: "Could not resolve the module specifier" on IOS

The webpack generate code looks ok:

        var file = tns_core_modules_file_system__WEBPACK_IMPORTED_MODULE_4__["knownFolders"].documents().getFile('test.js');
        var jsCode = "\n            module.exports = { test: function(str) { return 'x' + str; } }\n        ";
        file.writeTextSync(jsCode);
        import(/* webpackIgnore: true */ file.path)
            .then(function (res) {
            console.log('imported file res', res, res.test('y'));
        }).catch(function (err) {
            console.log('error', err);
        });

how can I fix this? I dont understand the error (what is not supported ?)
thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions