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

I get " ExperimentalWarning" on first build #55

Closed
Hejtmus opened this issue May 12, 2021 · 2 comments
Closed

I get " ExperimentalWarning" on first build #55

Hejtmus opened this issue May 12, 2021 · 2 comments

Comments

@Hejtmus
Copy link

Hejtmus commented May 12, 2021

Hello

I found this amazing adapter, after 3 hours lost on trying doing it manually.

So I installed this adapter according to the docs. But when I tried building it, I got this error:

> npx -y rimraf build && svelte-kit build --verbose

(node:584860) ExperimentalWarning: The ESM module loader is experimental.
Malformed svelte.config.js
SyntaxError: Unexpected token '.'
    at Loader.moduleStrategy (internal/modules/esm/translators.js:88:18)

Process finished with exit code 1

I tried to tinker around with configuration, but nothing fixed that error.

svelte.config.js

import preprocess from 'svelte-preprocess';
import adapter from 'svelte-adapter-firebase';
//import adapter from '@sveltejs/adapter-node';
//import adapter from '@sveltejs/adapter-static';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	// Consult https://github.com/sveltejs/svelte-preprocess
	// for more information about preprocessors
	preprocess: preprocess(),

	kit: {
		// hydrate the <div id="svelte"> element in src/app.html
		target: '#svelte',
		ssr: true,
		files: {
			assets: 'static'
		},
		adapter: adapter({
			firebaseJson: './firebase.json',
			cloudRunBuildDir: 'build'
		})
	}
};

export default config:

just standard config file

firebase.json

{
  "hosting": {
    "public": "static",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
  "rewrites": [
      {
        "source": "**",
        "function": "ssr"
      }
    ]
  },
  "functions": {
    "source": "build",
    "runtime": "nodejs14"
  }
}

package.json

{
  "name": "FIMTradeSolutions",
  "main": "functions.js",
  "version": "0.0.1",
  "scripts": {
    "dev": "svelte-kit dev",
    "build:classic": "svelte-kit build",
    "preview": "svelte-kit preview",
    "build": "npx -y rimraf build && svelte-kit build --verbose"
  },
  "devDependencies": {
    "@sveltejs/adapter-node": "^1.0.0-next.20",
    "@sveltejs/adapter-static": "^1.0.0-next.9",
    "@sveltejs/kit": "next",
    "bootstrap": "^5.0.0",
    "firebase-functions": "^3.13.2",
    "node-sass": "^6.0.0",
    "sass": "^1.32.12",
    "svelte": "^3.34.0",
    "svelte-adapter-firebase": "^0.6.5",
    "svelte-preprocess": "^4.0.0",
    "sveltestrap": "^4.2.1",
    "tslib": "^2.0.0",
    "typescript": "^4.0.0"
  },
  "type": "module"
}

Project files

Project files

Conclusion

Building process usually works, when I tried replacing this adapter for node, it fixed the problem (but I can't deploy it to firebase, because ESM doesn't run on cloud functions).

I read this project documentation several times, unfortunately I couldn't find any misconfiguration, but maybe I just didn't notice.

BTW, despite this error, I love this adapter, after 3 hours of attempting to deploy svelteKit app to firebase, I'm glad that project like this exists.

@jthegedus
Copy link
Owner

jthegedus commented May 12, 2021

@Hejtmus there was a change with SvelteKit @sveltejs/kit 1.0.0-next.104 which this adapter does not yet support. I am working on the update in #52

Because of this, the latest versions supported by this adapter is @sveltejs/kit 1.0.0-next.103

An unrelated note, you want your hosting.public field to be different to the SvelteKit files.assets dir as the adapter takes the files.assets (static dir in your config) and outputs them with the built app (non-ssr) files into hosting.public. The config you have atm is a conflict. Going to address in #56

The error you have hit is with your svelte.config.js format:

-export default config:
+export default config;

@jthegedus
Copy link
Owner

I will close this as I believe the intial cause should be resolved. Note that #52 will add support for @sveltejs/kit 1.0.0-next.104+, until then, please use @sveltejs/kit 1.0.0-next.103 as the SvelteKit version

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

No branches or pull requests

2 participants