Code Monkey home page Code Monkey logo

svelte-adapter-multi's Introduction

Svelte Multi Adapter

An adapter to launch multiple adapter

Installation

npm install --save-dev @macfja/svelte-multi-adapter
# or
pnpm add --save-dev @macfja/svelte-multi-adapter
# or
yarn add --dev @macfja/svelte-multi-adapter

Usage

Inside svelte.config.js:

import staticAdapter from '@sveltejs/adapter-static'
import nodeAdapter from '@sveltejs/adapter-node'
import multiAdapter from '@macfja/svelte-multi-adapter'

const config = {
    kit: {
        adapter: multiAdapter([staticAdapter(/* ... */), nodeAdapter(/* ... */)]),
        target: '#svelte',
    }
};

export default config;

Contributing

Contributions are welcome. Please open up an issue or create PR if you would like to help out.

Read more in the Contributing file

License

The MIT License (MIT). Please see License File for more information.

svelte-adapter-multi's People

Contributors

macfja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

svelte-adapter-multi's Issues

yarn add doesn't work

Subject of the issue

The command yarn add @macfja/svelte-adapter-multi doesn't work.

Your environment

  • Yarn version: 1.22.17
  • Node version: v17.2.0

Steps to reproduce

Run yarn add @macfja/svelte-adapter-multi

Expected behaviour

This should add the svelte-adapter-multi to the package json dependencies and download it to node_modules

Actual behaviour

An unexpected error occurred: "https://registry.yarnpkg.com/@macfja%2fsvelte-adapter-multi: Not found"

Adapter configuration object not passed correctly?

I have a simple sveltekit project where I need to link to resources not handled by sveltekit.
Therefore I needed to pass "strict: false" to svelte static adapter.
I also wanted to use a second adapter to crate a neutralino's app.

It works when I do it directly, like this:

import staticAdapter from '@sveltejs/adapter-static';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		adapter: staticAdapter({
		 	strict: false,
		 	pages: 'build/static',
		 	assets: 'build/static',
		 	fallback: 'index.html',
		 	precompress: false
		})
	}
};

export default config;

But it doesn't when I use it inside the multi adapter, like this:

import staticAdapter from '@sveltejs/adapter-static';
import multiAdapter from '@macfja/svelte-multi-adapter';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		adapter: multiAdapter([
			staticAdapter({
				strict: false,
				pages: 'build/static',
				assets: 'build/static',
				fallback: 'index.html',
				precompress: false
			})
		])
	}
};
export default config;

Error message:

 @sveltejs/adapter-static: all routes must be fully prerenderable, but found the following routes that are dynamic:
[...]
  You have the following options:
    - set the `fallback` option โ€” see https://kit.svelte.dev/docs/single-page-apps#usage for more info.
    - add `export const prerender = true` to your root `+layout.js/.ts` or `+layout.server.js/.ts` file. This will try to prerender all pages.
    - add `export const prerender = true` to any `+server.js/ts` files that are not fetched by page `load` functions.
    - pass `strict: false` to `adapter-static` to ignore this error. Only do this if you are sure you don't need the routes in question in your final app, as they will be unavailable. See https://github.com/sveltejs/kit/tree/master/packages/adapter-static#strict for more info.

These are my package.json dependencies:

	"devDependencies": {
		"@aleritty/svelte-adapter-neutralino": "git+https://github.com/aleritty/svelte-adapter-neutralino.git",
		"@fortawesome/svelte-fontawesome": "^0.2.0",
		"@macfja/svelte-multi-adapter": "^1.0.2",
		"@sveltejs/adapter-static": "^2.0.2",
		"@sveltejs/kit": "^1.20.2",
		"@typescript-eslint/eslint-plugin": "^5.59.11",
		"@typescript-eslint/parser": "^5.59.11",
		"autoprefixer": "^10.4.14",
		"daisyui": "^3.1.0",
		"eslint": "^8.42.0",
		"eslint-config-prettier": "^8.8.0",
		"eslint-plugin-svelte": "^2.30.0",
		"eslint-plugin-svelte3": "^4.0.0",
		"postcss-load-config": "^4.0.1",
		"prettier": "^2.8.8",
		"prettier-plugin-svelte": "^2.10.1",
		"sass": "^1.63.4",
		"svelte": "^3.59.1",
		"svelte-check": "^3.4.3",
		"svelte-i18n": "^3.6.0",
		"svelte-notifications": "^0.9.98",
		"svelte-preprocess": "^5.0.4",
		"tailwindcss": "^3.3.2",
		"tslib": "^2.5.3",
		"typescript": "^5.1.3",
		"vite": "^4.3.9"
	},

I'm not sure what can be the cause.

Promise.all should be used in adapt

Hello, I'm seeing this code:

export default function (adapters) {
    return {
        name: '@macfja/svelte-adapter-multi',

        async adapt(argument) {
            await adapters.forEach(item => Promise.resolve(item).then(resolved => resolved.adapt(argument)))
        }
    };
}

And I think it should be

await Promise.all(adapters.forEach...)

await adapters.forEach does not await for the promises

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.