Ad

Make A Instance From Entire Webpack Project

I have a project using a function class.

the webpack config part of the output is something like below:

...
output: {
    library: 'FirstPoint',
...

FirstPoint is first point to access main class, and main class at index.js (entry point) is something like:

import { onInit } from './intilize'
import { showSomeThing } './somthing'

export function MyClass(props) {
    onInit()
}

MyClass.prototype.showFoo = showSomeThing

the full example for this:

let myClass1 = new FirstPoint.MyClass()
let myClass2 = new FirstPoint.MyClass()
myClass1 .showFoo() //not show myClass1 detail, use last instance detail (myClass2)

after the run, all thing is done. just after creating another instance the showFoo method that using a function outside main class keep last value from the last instance.

I want to make instance for all new object that defines from MyClass class, Or, in other words, is there a way that I can import all the imported modules into the first level, ie, the main class, and instead of the output (production version) of an array of modules, there is only one modulus, and within that other modules, like the function?

Ad

Answer

One method for doing this, is using encapsulation, and the other way use a Param class!

Ad
source: stackoverflow.com
Ad