Angular软件包构建生成if(false){...}块

时间:2019-12-21 09:52:45

标签: angular webpack configuration package material

我在GitHub https://github.com/marcobuschini/parking-widget上有一个Angular软件包存储库,它可以测试全部绿色,并且使用ng build编译时没有错误。不幸的是,生成的代码在模块应导出的属性周围包含一些if (false) {...}语句。因此,该模块不起作用。我知道这是一个疯狂的配置选项。但是,通过阅读APF v9.0文档,我无法弄清楚哪个选项是错误的还是缺失的。

关于如何进一步调查该问题的任何想法?

谢谢。

1 个答案:

答案 0 :(得分:0)

angularCompilerOptions中的parking-widget/projects/widget/tsconfig.lib.json中更新if (false)以匹配问题中提到的APF 9.0文档中的内容后,exports: [WidgetComponent]语句消失了。

该小部件还无法正常工作。

经过进一步调查,我发现该小部件没有导出自身。因此,我在@NgModule文件的widget.module.ts部分中添加了import Vue from 'vue' import Vuex from 'vuex' import user from './user' import cart from './cart' import loading from './loading' import * as fb from 'firebase/app' Vue.use(Vuex) class Product { constructor (title, price, description, ownerId, imageSrc = '', id = null) { this.title = title this.price = price this.description = description this.ownerId = ownerId this.imageSrc = imageSrc this.id = id } } export default function (/* { ssrContext } */) { const Store = new Vuex.Store({ state: { amount: 1, products: [ ] }, getters: { addById (state) { return addId => { return state.products.find(product => product.id === addId) } }, products (state) { return state.products } }, actions: { async CREATE_PRODUCT ({ commit, getters }, payload) { commit('SET_LOADING', true) const image = payload.image try { const newProduct = new Product(payload.title, payload.price, payload.description, getters.user.id, '') const product = await fb.database().ref('products').push(newProduct) const imageExt = image.name.slice(image.name.lastIndexOf('.')) const fileData = await fb.storage().ref(`products/${product.key}.${imageExt}`).put(image) // const imageSrc = await fb.storage().ref().StorageReference(fileData.ref.fullPath).getDownloadUrl() const imageSrc = await fileData.ref.getStorage().getDownloadURL() await fb.database().ref('products').child(product.key).update({ imageSrc }) commit('SET_LOADING', false) commit('CREATE_PRODUCT', { ...newProduct, id: product.key, imageSrc }) } catch (error) { commit('SET_LOADING', false) throw error } }, async fetchProducts ({ commit }) { commit('SET_LOADING', true) const resultProducts = [] try { const fbVal = await fb.database().ref('products').once('value') const products = fbVal.val() Object.keys(products).forEach(key => { const product = products[key] resultProducts.push( new Product(product.title, product.price, product.description, product.imageSrc, product.ownerId, key) ) }) commit('LOAD_PRODUCTS', resultProducts) commit('SET_LOADING', false) } catch (error) { commit('SET_LOADING', false) throw error } } }, mutations: { CREATE_PRODUCT (state, payload) { state.products.push(payload) }, LOAD_PRODUCTS (state, payload) { state.products = payload } }, modules: { user, loading, cart }, strict: process.env.DEV }) return Store }