Open takahser opened 5 years ago
I found this example of JavaScript that becomes broken when compiled through webpack/vue-cli in production mode:
class TestClass {}
const TestNamespace = {}
TestNamespace[TestClass.name] = TestClass
class TestSubClass extends TestNamespace.TestClass {}
console.log(TestSubClass)
This looks like an issue with the minimizer used by webpack/vue-cli. Building in development mode (vue-cli-service build --mode=development
) won't cause the issue. I guess it is possible to somehow configure (or disable) the minimizer, but I am not an expert on vue-cli-service and webpack configuration.
hi @mar-v-in thank you for your reply. @takahser also added an issue on the vue-cli repo and here is their reply: https://github.com/vuejs/vue-cli/issues/3590#issuecomment-470819191
what's your thought on it?
@sisou any news on this? i hit the same problem on webpack production build
the only solution is disable minimize in production :/
module.exports = {
//...
optimization: {
minimize: false
}
};
ok worked with this too
minimizer: [
new TerserPlugin( {
extractComments: true,
cache: true,
parallel: true,
sourceMap: false, // Must be set to true if using source-maps in production
terserOptions: {
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
extractComments: "all",
keep_fnames: /Float32Array/, //https://github.com/mrdoob/three.js/issues/18540
mangle: {keep_classnames: true}, //https://github.com/nimiq/core-js/issues/482
compress: {
drop_console: true,
// passes: 3,
// keep_infinity: true
},
},
} ),
],
as shown in the comment https://github.com/nimiq/core-js/issues/482#issuecomment-472611483
the importend part is mangle: {keep_classnames: true}, //https://github.com/nimiq/core-js/issues/482
Thank you for your research and solution. The core-js library currently relies on global class names, which are indeed mangled by the production bundler.
For the browser package of Nimiq 2.0 Albatross, we hope to not rely on globals anymore and have a self-contained build.
hey @sisou,
what i read there is now way right now for a rust wasm Albatross build, would it make still sense to implement nimiq with the core-js for a webapp?
The Core Client API will (hopefully) not change significantly for Albatross.
So yes, building a Nimiq webapp is still a good idea with core-js now.
Experiments with compiling to WASM in core-rs-albatross are currently going on, but since the light consensus is also not 100% ready yet, a browser node from the rust code is not yet possible.
ok good to know! would be good to find a fix for this on nimiq core-js side or find a way to only not mangle global class names for core-js
@sisou no idea if this is relevant but on debug builds i still get
WARNING in ./node_modules/@nimiq/core-web/web.esm.js 1:95102-95112
Critical dependency: the request of a dependency is an expression
difficult to debug to find web.esm.js 1:95102-95112
New issue checklist
README
General information
Bug report
Expected behavior
@nimiq/core-web
should work in a VueJs app either of the following both scenarios:vue-cli-service serve
vue-cli-service build
and running from a webserver should also work.Actual behavior
vue-cli-service serve
works.vue-cli-service build
and running from a webserver doesn't work. Instead, it fails with a console error, which is varies in different browsers (for details, see 'Crash log' section)Steps to reproduce
git clone
the reproduction repo and run:Crash log