Skip to content

Upgrade to latest Svelte #1

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "svelte"]
path = svelte
url = https://github.com/awesome/svelte.git
url = https://github.com/sveltejs/svelte.git
10 changes: 0 additions & 10 deletions .hoeignore

This file was deleted.

1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.2
27 changes: 13 additions & 14 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# -*- ruby -*-
# frozen_string_literal: true

# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

source "https://rubygems.org/"
# Declare your gem's dependencies in vime_view_components.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

gem "execjs", "2.7.0"
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

gem "minitest", "~>5.10", :group => [:development, :test]
gem "hoe-yard", ">=0.1.3", :group => [:development, :test]
gem "hoe-bundler", ">=1.2", :group => [:development, :test]
gem "hoe-gemspec", ">=1.0", :group => [:development, :test]
gem "hoe-git", ">=1.6", :group => [:development, :test]
gem "yard", "~>0.8", :group => [:development, :test]
gem "redcarpet", "~>3.3", :group => [:development, :test]
gem "hoe", "~>3.16", :group => [:development, :test]

# vim: syntax=ruby
# To use a debugger
# gem 'byebug', group: [:development, :test]
32 changes: 32 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
PATH
remote: .
specs:
svelte-ruby (1.0)
execjs (~> 2.8)

GEM
remote: https://rubygems.org/
specs:
ansi (1.5.0)
builder (3.2.4)
execjs (2.8.1)
minitest (5.14.4)
minitest-reporters (1.4.3)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
rake (13.0.3)
ruby-progressbar (1.11.0)

PLATFORMS
ruby

DEPENDENCIES
minitest (~> 5.14)
minitest-reporters
rake
svelte-ruby!

BUNDLED WITH
2.1.4
23 changes: 0 additions & 23 deletions Manifest.txt

This file was deleted.

21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,28 @@ https://svelte.technology

The svelte-ruby gem ships with a working svelte source: `lib/svelte.js`. No need to regenerate it except for development or configuration.

The rollup task transpiles the svelte source to a format that's compatible with Execjs. The result is written to `lib/svelte.js` with these commands: `cd svelte && rollup -c rollup/rollup.config.ruby.js`

Copy config to svelte repo
The rollup task transpiles the svelte source to a format that's compatible with Execjs. The result is written to `lib/svelte.js` with these commands:

```
rake svelte:copy_config
cp lib/rollup/rollup.config.ruby svelte
cd svelte
rollup -c rollup.config.ruby.js
```

Transpile to Execjs compatible

```
rake svelte:rollup
```
You will also need to replace `self.performance.now()` in the generated JS with `null`;

### Dev Requirements

* [hoe](https://github.com/seattlerb/hoe) gem manager
* [hoe-bundler] may need `gem install hoe-bundler` installation before using `rake bundler:gemfile`
* [YARD](http://yardoc.org) docs
* [redcarpet](https://github.com/vmg/redcarpet) for yardoc
* [npm rollup] is needed locally to regenerate the svelte source for Execjs

[hoe-bundler]: https://github.com/flavorjones/hoe-bundler
[npm rollup]: https://www.npmjs.com/package/rollup

### Testing

Tests written with [minitest]

```
rake test
bundle exec rake test
```

[minitest]: https://github.com/seattlerb/minitest
Expand Down
65 changes: 8 additions & 57 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,61 +1,12 @@
# -*- ruby -*-
# frozen_string_literal: true

require "rubygems"
require "hoe"
require './lib/svelte/version.rb'
require "bundler/gem_tasks"
require "rake/testtask"

Hoe.plugin :gemspec
Hoe.plugin :minitest
Hoe.plugin :yard
Hoe.plugin :bundler
Hoe.plugin :git
Hoe.plugin :ignore

Hoe.spec "svelte" do
developer("So Awesome Man", "[email protected]")
license "MIT" # this should match the license in the README

self.name = 'svelte-ruby'
self.version = Svelte::VERSION
self.summary = 'Ruby Gem wrapper for the Svelte compiler'
self.email = '[email protected]'
self.description = self.summary
self.urls = ['https://github.com/bordeeinc/svelte-ruby']
self.testlib = :minitest
self.readme_file = 'README.md'
self.history_file = 'History.txt'

# third-party
self.yard_title = self.name
self.yard_markup = 'markdown'

self.extra_deps += [
['execjs', '2.7.0']
]

self.extra_dev_deps += [
["hoe-bundler", ">= 1.2"],
["hoe-gemspec", ">= 1.0"],
["hoe-git", ">= 1.6"],
["minitest", "~> 5.9.0"],
["yard", "~> 0.8"],
["redcarpet", "~> 3.3"] # yard/markdown
]

self.clean_globs += [
'.yardoc',
'vendor',
'Gemfile.lock',
'.bundle',
]

self.spec_extras = {
:required_ruby_version => '>= 1.9.2'
}
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end

# require rake tasks
current_dir = File.expand_path(File.dirname(__FILE__))
Dir.glob(File.join(current_dir, 'lib/tasks/*.rake')).each {|r| import r}

# vim: syntax=ruby
task default: :test
62 changes: 0 additions & 62 deletions bin/svelte

This file was deleted.

75 changes: 48 additions & 27 deletions lib/rollup/rollup.config.ruby.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import buble from 'rollup-plugin-buble';
import fs from 'fs';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import sucrase from '@rollup/plugin-sucrase';
import typescript from '@rollup/plugin-typescript';
import pkg from './package.json';

export default {
entry: 'src/index.js',
moduleName: 'svelte',
targets: [
{
dest: '../lib/svelte.js',
format: 'iife'
}
],
plugins: [
nodeResolve({ jsnext: true, module: true }),
commonjs(),
json(),
buble({
include: 'src/**',
exclude: 'src/shared/**',
transforms: {
dangerousTaggedTemplateString: true
}
})
],
sourceMap: true
};
const is_publish = !!process.env.PUBLISH;

const ts_plugin = is_publish
? typescript({
include: 'src/**',
typescript: require('typescript')
})
: sucrase({
transforms: ['typescript']
});

const external = id => id.startsWith('svelte/');

fs.writeFileSync(`./compiler.d.ts`, `export { compile, parse, preprocess, walk, VERSION } from './types/compiler/index';`);

export default [
// ruby
{
input: 'src/compiler/index.ts',
plugins: [
replace({
__VERSION__: pkg.version
}),
resolve(),
commonjs({
include: ['node_modules/**']
}),
json(),
ts_plugin
],
output: [
{
file: '../lib/svelte.js',
format: "iife",
name: 'svelte',
sourcemap: false,
},
]
}
];
Loading