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

Snapshot fails with nativescript-dev-webpack versions > 0.21.2 #920

Closed
KkevinLi opened this issue May 31, 2019 · 2 comments
Closed

Snapshot fails with nativescript-dev-webpack versions > 0.21.2 #920

KkevinLi opened this issue May 31, 2019 · 2 comments
Assignees
Labels

Comments

@KkevinLi
Copy link

Environment
✔ Getting NativeScript components versions information...
✔ Component nativescript has 5.4.0 version and is up to date.
✔ Component tns-core-modules has 5.4.1 version and is up to date.
✔ Component tns-android has 5.4.0 version and is up to date.
✔ Component tns-ios has 5.4.0 version and is up to date.

  • Node.js: v10.14.0

Describe the bug

After upgrading nativescript-dev-webpack to 0.24.0 (and those > 0.21.2) I get the following error when doing a snapshot build:

ERROR in NativeScriptSnapshot. Snapshot generation failed!
Target architecture: arm64-v8a


#
# Fatal error in , line 0
# Check failed: blob.data.
#
#
#
#FailureMessage Object: 0x7ffeee2f8c00
==== C stack trace ===============================

    0   mksnapshot-arm64                    0x0000000102d14e43 mksnapshot-arm64 + 21065283
    1   mksnapshot-arm64                    0x0000000102d19dfb mksnapshot-arm64 + 21085691
    2   mksnapshot-arm64                    0x0000000102d0f915 mksnapshot-arm64 + 21043477
    3   mksnapshot-arm64                    0x00000001019007ed mksnapshot-arm64 + 10221
    4   libdyld.dylib                       0x00007fff6b93b3d5 start + 1
    5   ???                                 0x0000000000000006 0x0 + 6

Executing webpack failed with exit code 2.

To Reproduce

tns build android --compileSdk 28 --env.aot --env.snapshot --env.release --env.uglify --env.sourceMap --release --keyStorePath path --keyStorePassword pass --keyStoreAlias alias --keyStoreAliasPassword pass

Additional context

0ae6030

^ If I comment out line 176: semicolons: !isAnySourceMapEnabled my build does work.

@m-abs
Copy link

m-abs commented Jun 7, 2019

I'm seeing the same problem here. sourceMap + uglify + snapshot breaks.

Thank you @KkevinLi for the workaround.

@DimitarTachev
Copy link
Contributor

Hi @KkevinLi and @m-abs

Thanks for reporting and investigating this and sorry for the late response!

I do not recommend you using the above-mentioned workaround as the source maps are not working properly with semicolons: true and you will get misleading stack traces when you apply the source maps.

We were able to investigate this and I've opened a pull request with a fix. It was caused by the snapshot plugin which was joining a few files by a newline. When we pass semicolons: false to the Terser plugin, the output files are IIFEs without ; at the end and joining these IIFEs by a newline is generating an invalid JavaScript code.

You could easily test the fix even before the plugin release by replacing

const inputFilesContent = inputFiles.map(file => fs.readFileSync(file, "utf8")).join("\n");

with

const inputFilesContent = inputFiles.map(file => fs.readFileSync(file, "utf8")).join("\n;");

in your node_modules/nativescript-dev-webpack/snapshot/android/snapshot-generator.js file.

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

No branches or pull requests

5 participants