ruby-next icon indicating copy to clipboard operation
ruby-next copied to clipboard

Using RubyNext in gems without a runtime dependency

Open eregon opened this issue 3 years ago • 3 comments

From https://github.com/ruby-next/ruby-next/issues/100#issuecomment-1282607086

So we'd run ruby-next nextify to create the files, and paste something like $LOAD_PATH.unshift "#{__dir__}/.rbnext" but wouldn't need any require 'ruby-next'. The reason is the transpiled files would only be used on some Ruby implementations, and we wouldn't to add a dependency to the gem for all Ruby implementations.

This mostly already works with ruby-next nextify -V --rewrite=pattern-matching --no-refine ./lib, but would need documentation in https://github.com/ruby-next/ruby-next#integrating-into-a-gem-development

eregon avatar Oct 18 '22 17:10 eregon

This mostly already works with ruby-next nextify -V --rewrite=pattern-matching --no-refine ./lib

And, I think, adding --single-version is required in this cases (so .rbnext contains the transpiled files for the minimum supported version, not for multiple versions in subfolders, .rbnext/2.7, .rbnext/3.0, etc.)

palkan avatar Oct 18 '22 17:10 palkan

Right. Currently that command-line already behaves as --single-version even when not passing it.

eregon avatar Oct 18 '22 17:10 eregon

Oh, right, that's because specifying rewriters explicitly implies having a single version: https://github.com/ruby-next/ruby-next/blob/cabf5829ee6939d23481ed74eb20809e2191eeac/lib/ruby-next/commands/nextify.rb#L211

palkan avatar Oct 18 '22 17:10 palkan