-
Notifications
You must be signed in to change notification settings - Fork 13
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
Dynamic import is not enabled in this context (deno-deploy) #40
Comments
@ThibaudMZN thanks for your feedback, I'm also getting the same error on one of my websites on Deno Deploy, it's most likely related to the esbuild->rollup migration or some misconfiguration, I'll work on fixing it. |
Thanks for your quick answer ! |
Is this due to |
@jpaquim I can confirm that on version 0.9.0, I have the same error, and I don't have errors on 0.8.2. |
I am running into the same error, any fixes? |
@CodeLikeCrazE I haven't had the time to look into this yet, but it's likely related to differences between esbuild and rollup or a rollup misconfiguration. I'll try to dig deeper into this over the coming week. |
+1 on this. I've tried to deploy the basic demo app to test this adapter and deno deploy, but ran into this issue. |
I also ran into this and was able to fix it by downgrading from v0.9.0 to v0.8.2. Thanks for the tip @ashxdev! |
Oh, and it may also be worth noting that I didn't run into the issue until I added an import from |
This issue is that Deno Deploy cannot dynamically import modules. Rollup generates code like: const component = async () => (await import('./_page.svelte.js')).default; The I looked at how the Netlify adapter works for Netlify Edge functions because those actually run on Deno Deploy. It is using esbuild instead of Rollup and bundling a single file combining the A simple Deno Deploy adapter I have working: import {writeFileSync} from 'fs';
import {build} from 'esbuild';
export default function (opts = {}) {
const {out = 'build'} = opts;
return {
name: 'deno-deploy-adapter',
async adapt(builder) {
const tmp = builder.getBuildDirectory('deno-deploy-adapter');
builder.rimraf(out);
builder.rimraf(tmp);
builder.mkdirp(tmp);
const outDir = `${out}/static/${builder.config.kit.paths.base}`;
builder.writeClient(outDir);
builder.writePrerendered(outDir);
builder.writeServer(`${tmp}/server`);
const manifest = builder.generateManifest({
relativePath: './'
});
writeFileSync(
`${tmp}/server/manifest.js`,
`export const manifest = ${manifest};\n\nexport const prerendered = new Set(${JSON.stringify(
builder.prerendered.paths
)});\n`
);
writeFileSync(
`${tmp}/server.js`,
`
import {Server} from './server/index.js';
import {manifest} from './server/manifest.js';
const server = new Server(manifest);
export default server;
`
);
build({
entryPoints: [`${tmp}/server.js`],
outfile: `${out}/server.js`,
bundle: true,
format: 'esm',
target: 'esnext'
}).catch((err) => {
console.error(err);
process.exit(1);
});
}
};
} And the actual Deno Deploy entry point: import {serve} from 'https://deno.land/[email protected]/http/server.ts';
import {serveDir} from 'https://deno.land/[email protected]/http/file_server.ts';
import server from './build/server.js';
const initialized = server.init({env: Deno.env.toObject()});
serve(async (request, context) => {
const response = await serveDir(request, {
fsRoot: 'build/static',
quiet: true
});
if (response && (response.ok || response.status < 400)) {
const url = new URL(request.url);
if (url.pathname.startsWith('/_app/immutable/')) {
response.headers.set(
'cache-control',
'public, max-age=31536000, immutable'
);
}
return response;
}
await initialized;
return server.respond(request, {
platform: {context},
getClientAddress() {
return context.remoteAddr.hostname;
}
});
}); I'm not sure the best way to integrate such a "fix" for the |
I'm working on a Deno Deploy compatible adapter here: Based on the code above but with a few fixes and improvements. |
Hey @dbushell! Thank you for looking into this issue, unfortunately I haven't really been using Deno or Deno Deploy lately, so I haven't had the time to look into this. As mentioned above, this breaking change in compatibility in the 0.9 release was due to migrating from esbuild to rollup, which I think I'll just end up reverting. Feel free to propose any change to this repo, I'll take a look at your repo as well. |
Hi, I tried using the adapter and push my code to deno deploy but I'm getting this error when loading the published site :
I was wondering if you ever encountered this problem ?
The text was updated successfully, but these errors were encountered: