GigaGrid icon indicating copy to clipboard operation
GigaGrid copied to clipboard

Create lib folder with source files for building with technologies such as webpack

Open caguthrie opened this issue 7 years ago • 7 comments

Current version in npm only has a file in the dist/ folder which includes dependancies such as jQuery. Let's have package.json point to a lib/index.ts file which would be the untry point for loading this when using things like webpack. This will solve potentially duplicating dependancies by a developer and reduce bundled file size

caguthrie avatar Nov 04 '16 17:11 caguthrie

One concern I have is for people who are not using typescript but requires the contents of the library

We could strike a balance by putting into the lib folder ES6 classes instead. But then we lose the type definitions.

What do you think?

erfangc avatar Nov 04 '16 17:11 erfangc

I just tried it naively and the Application would fail for a few reasons

  • Client application's tsconfig.json would have to not exclude node_modules as giga-grid would be located there, otherwise ts-loader for webpack will not be applied to the GigaGrid ts files
  • Certain libraries such as Flux, lodash and jQuery must be added as dependencies and not devDependencies in GigaGrid

Even then - I was getting an error implying ts-loader is not being activated for files located in node_modules

erfangc avatar Nov 06 '16 16:11 erfangc

I'll mess around with this this week. There should be a way we can make it work to your prior reply, we should still have a dist folder with a compiled js file in it, but remove jquery as we should expect a user to import it themselves

On Nov 6, 2016, at 11:23 AM, Erfang Chen [email protected] wrote:

I just tried it naively and the Client Application would fail for a few reasons

Client application's tsconfig.json would have to not exclude node_modules as giga-grid would be located there, otherwise ts-loader for webpack will not be applied to the GigaGrid ts files Certain libraries such as Flux, lodash and jQuery must be added as dependencies and not devDependencies in GigaGrid Even then - I was getting an error implying ts-loader is not being activated for files located in node_modules

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

caguthrie avatar Nov 06 '16 17:11 caguthrie

@caguthrie thanks, here are some findings,

I was able to get things to work by just making "main" = "src/index.ts" in "package.json"

We then need to make sure that "node_modules" is not excluded in the application's webpack.config's loader configs or tsconfig.json

but then you will see compilation errors - and those are largely due to missing flux typing files (which can be installed via typings)

erfangc avatar Nov 07 '16 03:11 erfangc

@erfangc, here are some thoughts.

If we add "jquery": ">= 2.0.0" to the peerDependencies section in package.json and don't include it in the build, then our problem is really solved. The file in the dist dir will be obviously much smaller, not bundle the dependency in, and yell at a user if they don't have jquery in their project's node_modules dir. We could spend time in figuring out the right we to get webpack to build files out of the src directory, but there might not much benefit here.

caguthrie avatar Nov 07 '16 20:11 caguthrie

Would not using the complied version be easier to facilitate proper typings? Is this what I'm missing here?

caguthrie avatar Nov 07 '16 21:11 caguthrie

The compiled a version is written in ECMAScript6, or5

erfangc avatar Nov 08 '16 10:11 erfangc