类Object不是构造函数

时间:2019-02-26 06:13:20

标签: javascript node.js vue.js npm

我创建了自己的Vue.js npm库来帮助我进行个人项目。一切正常,除了尝试导入import org.apache.spark.sql.expressions.Window import org.apache.spark.sql.functions.rank import org.apache.spark.sql.functions.col val window = Window.partitionBy("user_id").orderBy('score desc) val rankByScore = rank().over(window) df1.select('*, rankByScore as 'rank).filter(col("rank") <= 2).show() # you can change the value 2 to any number you want. Here 2 represents the top 2 values

我已经这样定义了类:

Class

我的npmpackages.json:

import Vue from 'vue'

export default class Foo {
  constructor () {
    ...
  }
}

要发布,我先做"main": "./dist/my-custom-lib.common.js", "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "build-bundle": "vue-cli-service build --target lib --name my-custom-lib ./index.js", "test:unit": "vue-cli-service test:unit" }, "files": [ "dist/my-custom-lib.common.js", "src/components/*", "src/controllers/*", "src/mixins/*", "src/utilities/*" ], ,然后再做yarn build-bundle

当我尝试从其他项目中导入它时:

npm publish

我收到以下错误:

import { Foo } from '@username/my-custom-lib'

我可以使用所有其他函数/ mixins / vue组件,但不能使用此类。

编辑:这是global-plugin.js?3d38:9 Uncaught TypeError: _username_my_custom_lib__WEBPACK_IMPORTED_MODULE_2__.Foo is not a constructor 文件的部分内容:

common.js
称为var foo_Foo = /*#__PURE__*/ function () { function Foo(router) { _classCallCheck(this, Foo); } _createClass(Foo, [{ ...source contents... }]); return Foo; }(); /* concated harmony reexport foo */__webpack_require__.d(__webpack_exports__, "foo", function() { return foo_Foo; });

index.js包含以下内容:

yarn build-bundle

import * as components from '@/components' const VueComponents = { install (Vue) { for (const plugin in components) { Vue.component(plugin, components[plugin]) } } } export * from '@/mixins' export * from '@/utilities' export * from '@/controllers' export default VueComponents 内部:

@/controllers/index.js

0 个答案:

没有答案