Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

npm build:ios creates a file which references the src #12

Closed
tuqire opened this issue Mar 9, 2018 · 13 comments
Closed

npm build:ios creates a file which references the src #12

tuqire opened this issue Mar 9, 2018 · 13 comments

Comments

@tuqire
Copy link

tuqire commented Mar 9, 2018

Hi,

So I appear to be seeing a weird issue, not sure if I am doing something stupid (apologies new to NativeScript).

I have taken this project down as described and ran npm run build:ios inside the repo. The file generated in dist/app/app.ios.js doesn't actually contain any transpiled code. Its export is a require of the src.main.js file. Removing the webpack helper functions, I am left with the below:

e.exports=require("/Users/USER/Documents/repos/nativescript-shared-components-spike/nativescript-app/src/main.js")

Is this by design? tns --path dist run ios causes an app crash with the following error file:///Users/USER/Documents/repos/nativescript-shared-components-spike/nativescript-app/src/styles.scss:3:563: JS ERROR SyntaxError: Invalid character: '@'.

Any help would be greatly appreciated.

@lewebsimple
Copy link
Contributor

Did you initialize your project using vue init nativescript-vue/vue-cli-template nativescript-app?
What versions of Node / NPM are you using?
Do 'classic' NativeScript projects work in your environment? (i.e. tns create testapp)

@triniwiz
Copy link

triniwiz commented Mar 9, 2018

@tuqire i'm getting the same problem to get rid of the Invalid character: '@' removed the import of the style and well android can't find the main file :/

@triniwiz
Copy link

triniwiz commented Mar 9, 2018

Node v8.9.4
Npm 5.6.0

Some extra info

@lewebsimple
Copy link
Contributor

Please share a repo with your project so we can test the actual core

@triniwiz
Copy link

triniwiz commented Mar 9, 2018

https://github.com/triniwiz/nativescript-pager it's in the demo-vue 😃

@tuqire
Copy link
Author

tuqire commented Mar 9, 2018

@lewebsimple yes I did initialise it like that. I have left work and don't have my laptop, so will get back to you Monday.

@triniwiz if you find a solution please do share it here.

@tuqire
Copy link
Author

tuqire commented Mar 12, 2018

@lewebsimple

Node: 8.9.1
NPM: 5.7.1

I have just tried another bootstrap vue app and it worked fine. If it helps, I only installed nativescript on Friday, possibly something has changed in a new release?

@tuqire tuqire closed this as completed Mar 13, 2018
@tuqire
Copy link
Author

tuqire commented Mar 13, 2018

The fix was removing the nativescript-vue-externals from webpack.externals. Something about it is not playing nice with webpack. Doing some investigating now to figure out why.

@tuqire
Copy link
Author

tuqire commented Mar 13, 2018

So debugged the issue.

nativescript-vue-externals looks for the string nativescript- in the names of our dependencies to know which dependencies to exclude. However, the first time it is called it is called with the projects path, meaning if the file path contains nativescript- or tns-core-modules the entire build process falls apart. Basically, rename your folder to not include either of those two strings.

@lewebsimple
Copy link
Contributor

lewebsimple commented Mar 13, 2018

Maybe we should add a validation check for 'name' to prevent people from naming their projects nativescript-* ?

@tuqire
Copy link
Author

tuqire commented Mar 13, 2018

Yes that would make sense, I think when spiking it is very convenient to name something weex-spike nativescript-spike etc. However, it still doesn't stop anyone renaming the folder later, hopefully this thread will help them.

@rigor789
Copy link
Member

I think we need to figure out a better way to mark externals, and at this point I feel like a manually managed list might be a better idea. Or mark dependencies as external, and don't mark devDependencies as externals. This is probably a safe bet, because most people will --save their deps, and everything will work, just not get bundled and instead will be handled as external. This is fine, and when someone reaches the point where they would like to improve performance, they can just move the dependencies around, as long as this is documented.

@triniwiz
Copy link

triniwiz commented Mar 15, 2018

So i think the way tns know it's a nativescript is by checking the package.json for the following it can be a lower platform version also

 "nativescript": {
        "platforms": {
            "android": "3.0.0",
            "ios": "3.0.0"
        }
    },

@nativescript-vue nativescript-vue locked as resolved and limited conversation to collaborators May 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants