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

start work on #166 #177

Closed
wants to merge 4 commits into from
Closed

start work on #166 #177

wants to merge 4 commits into from

Conversation

Rich-Harris
Copy link
Member

This starts to address #166, by creating a Builder class (naming subject to yak-shaving) that gets passed to adapters. The idea is that rather than adapters making assumptions about file structure and having to import various helper functions from app-utils, everything is co-located in a way that reduces code duplication etc.

So adapter-static goes from this...

import { RouteManifest } from '@sveltejs/app-utils';
import { copy } from '@sveltejs/app-utils/files';
import { prerender } from '@sveltejs/app-utils/renderer';
import { Logger } from '@sveltejs/app-utils/renderer/prerender';

module.exports = async function adapter({
  dir,
  manifest,
  log
}: {
  dir: string;
  manifest: RouteManifest;
  log: Logger;
}) {
  const out = 'build'; // TODO implement adapter options

  copy('static', out);
  copy(`${dir}/client`, `${out}/_app`);

  prerender({
    force: true,
    dir,
    out,
    manifest,
    log
  });
};

...to this:

module.exports = async function adapter(builder) {
  builder.copy_static_files('build');
  builder.copy_generated_files('build/_app');

  builder.prerender({
    force: true,
    dest: 'build'
  });
};

Not pictured: a way for the adapter to verify that the builder API is the version that it expects (e.g. builder.check_version('^1.0.0'), which would throw if the version of @sveltejs/kit that provided the builder was at version 2.0.0 or above).

My progress has been somewhat hampered by TypeScript errors that are preventing me from actually writing the PR.

}

copy_static_files(dest: string) {
copy(this.#static_files, dest);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is giving me Usage of undeclared private name, which is probably what your issue is

@Rich-Harris Rich-Harris mentioned this pull request Nov 25, 2020
@Rich-Harris
Copy link
Member Author

closing in favour of #180

@Rich-Harris Rich-Harris deleted the gh-166 branch November 26, 2020 00:19
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