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

Publish as package for Deno, Node, and the browser #9

Closed
dslmeinte opened this issue Dec 25, 2022 · 15 comments
Closed

Publish as package for Deno, Node, and the browser #9

dslmeinte opened this issue Dec 25, 2022 · 15 comments
Labels
enhancement New feature or request

Comments

@dslmeinte
Copy link
Contributor

Involves:

This issue replaces issues #1 and #5.

@dslmeinte dslmeinte added the enhancement New feature or request label Dec 25, 2022
This was referenced Dec 25, 2022
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 9, 2023
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 14, 2023
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 14, 2023
dslmeinte pushed a commit that referenced this issue Mar 14, 2023
* #9 build an NPM package. Tested in a Node project.

* #9 build an NPM package. Tests now pass for the generated package.

* #9 update lock file
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 14, 2023
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 15, 2023
@alessiostalla
Copy link
Contributor

I've tried using the NPM package in the browser with several shims, but it doesn't seem possible right now. The deno-shim package requires and uses many Node APIs. In particular, now I'm stuck at

mainModule.js:8 Uncaught TypeError: (0 , url_1.pathToFileURL) is not a function
    at ../node_modules/@deno/shim-deno/dist/deno/stable/variables/mainModule.js (mainModule.js:8:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ../node_modules/@deno/shim-deno/dist/deno/stable/variables.js (variables.js:37:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ../node_modules/@deno/shim-deno/dist/deno/stable/functions/chdir.js (chdir.js:10:1)
    at options.factory (react refresh:6:1)

b/c the "url" package doesn't include Node's pathToFileURL function.

The main problem seems to be that Deno's Node shim is monolithic and uses all sorts of Node APIs, which doesn't play nice with the browser.

@dslmeinte
Copy link
Contributor Author

What APIs is the code really using? Only the test code uses filesystem-related APIs, right? Maybe we can split off all test code to a separate directory? That would mean that the tests also mimic the “use as library/package” situation more.

@alessiostalla
Copy link
Contributor

parse uses the Deno XML module which in turn uses fs, etc.
I think "dnt" is already taking care of separating the tests from the production code.
Funny that my spell-checker insists correcting "dnt" to "don't" 🤣

@dslmeinte
Copy link
Contributor Author

Ironic that something (XML parsing) that should be really very portable is an obstacle to portability now...

We can also separate out the parsing-part of the Ecore-importer, keeping just the types that an XML parser is supposed to return, with the remark that the XML parser currently used is compatible with that. What do you think?

@alessiostalla
Copy link
Contributor

alessiostalla commented Mar 16, 2023 via email

@dslmeinte
Copy link
Contributor Author

OK, I'll try and do that first, then.

By the way: how do you check whether the package works in the browser? Can we integrate that into this repository?

@alessiostalla
Copy link
Contributor

Currently, I have another project where I manually add the Lioncore dependency and open a demo page in a browser. That could be automated, I think.

@dslmeinte
Copy link
Contributor Author

If you have some time and opportunity, it'd be great (“stallar” even 😄) if you could add that!

@dslmeinte
Copy link
Contributor Author

I split off the test code and its dependency management to a separate directory in this branch: https://github.com/LIonWeb-org/lioncore-typescript/tree/node-compatibility

Can you check whether that'd already solve some of the problems? The next step would probably be to modify build_npm.ts to not “drag in” any test dependency, right?

@alessiostalla
Copy link
Contributor

A stalla is a farm animal shed, so "stallar" doesn't sound that nice lol 🤣
I'll try that!

@dslmeinte
Copy link
Contributor Author

Depends on the shed! 😆 (Incidentally: in Dutch “stal” means the same thing, including the derogatory association.)

@alessiostalla
Copy link
Contributor

Cool!
Your branch appears to be solving the problem, yay! At least I can instantiate a node and obtain a Concept. We'll see going forward what's there to be added/removed in the module's exports.

@dslmeinte
Copy link
Contributor Author

OK, I'll just merge that branch into main, and see whether the integration tests have a problem.

@dslmeinte
Copy link
Contributor Author

Done, and fixed integration test setup as well. I'm closing this issue. Follow-up improvements can be associated with other issues.

@ftomassetti
Copy link
Contributor

Very happy about this one!

alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 16, 2023
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 16, 2023
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 16, 2023
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 16, 2023
alessiostalla added a commit to Strumenta/lioncore-typescript that referenced this issue Mar 16, 2023
dslmeinte pushed a commit that referenced this issue Mar 27, 2023
* #9 build an NPM package. Tested in a Node project.

* #9 build an NPM package. Tests now pass for the generated package.

* #9 update lock file

* #9 provide mod.ts as an entry point for the NPM module

* #9 export more symbols for the Node package

* #9 build an NPM package. Tested in a Node project.

* #9 build an NPM package. Tests now pass for the generated package.

* #9 update lock file

* #9 provide mod.ts as an entry point for the NPM module

* #9 export more symbols for the Node package

* Delete scripts/build_npm.ts (wrong merge)

* Fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants