Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build and import TKO-beta as a bundled library. #178

Open
Mikhail-Ananev opened this issue Jul 7, 2022 · 3 comments
Open

How to build and import TKO-beta as a bundled library. #178

Mikhail-Ananev opened this issue Jul 7, 2022 · 3 comments

Comments

@Mikhail-Ananev
Copy link

Hello.
I'm trying to build and import recent TKO-beta version at my TS project built from source (as of npm-hosted version is alpha7).
So, I cloned that repo and run "make" (if I understood correctly, the default is make 'all', which uses npx'ed Lerna as packager for individual of packages from the monorepo in packages and calls their builders) command from root of the repo, then I got "builds" folder with 2 folder inside: "knockout" and "reference". Right now i'm struggling to pinpoint/understand the functional difference between these two versions of TKO, and the purpose of the 'reference' build. I'd really appreciate some advice.

Looks like the TKO library should be ready to be imported right from dist directory, but different file depending of used in-project modules. I understood that there are multiple build targets for different types of modules like ECM or commonJS, etc., and while using the build with ECM, i should be using the import ko from "<arbitrary path>/libs/tko/builds/knockout/dist/index.js" build. Please, correct me if i'm wrong. And, may it possibly be connected to #158 ?

Also, if these questions are resolved, may I contribute to a readme for more clearance/updated guide on the build-to-usage pipeline. Right now I'm looking into #134 by which way the build process may be improved.
Thank you!

@ironkayman
Copy link

ironkayman commented Jul 8, 2022

Hi!
Its just my guess - seems like that these are bundled yarn add @tko/build.reference and yarn add @tko/build.knockout from project readme. Basically, quoting readme:

The Knockout build has some backwards compatibility that is not in the reference build.  See the build differences, here: https://tko.io/3to4

It's available as `@tko/build.knockout`, and over CDN:

is a compatibility-oriented build, while build.reference is canonical TKO 4 beta 1.3 without further compatibilities. I'll look into it.

UPD 1: yeah, builds/reference/package.json: "name": "@tko/build.reference",

UPD 2: calling make from project root builds bundles, builds/reference/index.ts tells about unknown version of TKO, while with importing dist/index.js as ESM, ko.applyBindings does not seem work with components in inlined DOM nodes, at which bindings were applied (for a whole document in my case, by default) Right now I could advice until somebody tells otherwise to build from tags/4.0.0-alpha9 with npm i -> npm run build -> and than use/call import ko from "<...your arbitrary path...>/tko/packages/tko/dist/tko.es6.min.js" as that build works fine as up now for me (i guess). I'll look further into beta* builds.

@ironkayman
Copy link

ironkayman commented Jul 20, 2022

Hi, so working with beta1.3 tag the problem seems to be in some circular deps (my guess):

ECS

Importing with anything like:

import * as ko from "tko/builds/reference/dist/index.js"
import ko from "tko/builds/reference/dist/index.js"
import tko from "tko/builds/reference/dist/index.js"

i'm getting TypeError: Class extends value undefined is not a constructor or null


browser.js

but, calling

import "tko/builds/reference/dist/browser.min.js"
// and then for compatibility
const ko = tko

does the trick

@ironkayman
Copy link

Hi! I think this issue can be closed due to #179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants