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

Try loading plugin by name if file not in source-tree #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

neochrome
Copy link

Hi!
I stumbled upon your project whilst learning more about c64 assembly dev and I really like what you've accomplished - powerful and versatile as KickAss but simple to extend and quick and easy to get going!

While I agree that keeping project specific plugins together with the source is a good idea, I still believe that some kinds of plugins (e.g sid-loading) could benefit from being packaged as separate modules, kinda like the Node stdlib. Also community developed generic modules could be supported.

Anyway, here is an initial take on how to possible support this by introducing a slight change with regards to how plugin paths are currently resolved. What do you think?

Please note that the proposed change will introduce a breaking change in the !use pseudo op to make it's behavior mirror that of Node's require. Plugins referred to with a prefix of either ., ./ or / will still be loaded directly from the file system as today, whereas "plain" names will try to load the plugin from the node_modules folder.

I haven't added test cases for this yet, as I would like to run this by you first and don't really have a good idea on how to ship a test plugin module for inclusion besides actually adding it to node_modules - but that should be solvable.

Regards,
Johan

@nurpax
Copy link
Owner

nurpax commented Jul 29, 2019

Thanks for the suggestion and the PR. I'll need to give this some thought -- I'll reply in more detail later. I'm in the middle of implementing !use to work in the web browser (now it works only on Node) and this may complicate things a little bit.

When you're talking about node_modules, do you mean just accessing files bundled with the c64jasm package, or are you looking for a general npm install c64jasm-sid, !use "c64jasm-sid" as sid style functionality? I think I'm a little bit averse to the latter as I'm not a big fan of hiding fairly simple functionality (sid loading is just one function) behind npm packages. This is assembler coding after all, so it's good for developers to understand how their tools work. (But I think you already know my position on this, given your earlier comments. :))

If you're just looking to bundle things into some stdlib that comes with c64jasm, there may be some other alternatives that'd work in the browser too.

Another approach that I've had in mind would be for c64jasm to support something like project templates, like c64jasm init which would create the boilerplate for you. E.g., just something like:

/src
/src/plugins/c64-stdlib.js  # this would contain the sid loader
/src/main.asm      # entry point
/src/macros.asm  # macros for +basic_start for c64 prgs

This of course is not upgradable in case something needs to change in any of the files generated by init. But if it's really simple stuff (like it tends to be in assembly), that's probably not an issue.

I don't intend to plan for a "c64jasm npm ecosystem of packages" because at least at the moment, c64jasm is a pretty niche project given that c64 developers tend to use KA, ACME and 64tass. If there are only a handful of users, it feels like too much indirection to stick stuff on NPM.

Anyway, hopefully this doesn't feel like I'm trying to shoot your idea down. I'd also like some solution but want to first discuss what'd be a clean and concrete way to implement this.

@nurpax
Copy link
Owner

nurpax commented Jul 29, 2019

Re: !use "foo" vs. !use './foo. We could also introduce something like !use @stdlib/foo` for importing prebuilt packages. I kind of like the current !use path handling as it works the same way as !include. (Fully realizing that Node works differently.)

@neochrome
Copy link
Author

neochrome commented Jul 29, 2019 via email

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

Successfully merging this pull request may close these issues.

2 participants