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

Cannot get sitePath to work #630

Closed
ItalyPaleAle opened this issue Jul 16, 2023 · 3 comments
Closed

Cannot get sitePath to work #630

ItalyPaleAle opened this issue Jul 16, 2023 · 3 comments

Comments

@ItalyPaleAle
Copy link

Trying to start Miniflare serving a site too, with this code:

const mf = new Miniflare({
    host: options.address,
    port: options.port,
    workers: [
        {
            name: 'myapp',
            script: script.toString('utf8'),
            scriptPath: 'index.mjs',
            modules: true,
            modulesRules: [{type: 'ESModule', include: ['**/*.js', '**/*.mjs']}],
            compatibilityDate: '2023-05-18',
            sitePath: options.sitePath,
        },
    ],
})

However, this fails with:

MiniflareCoreError [ERR_MODULE_RULE]: Unable to resolve "index.mjs" dependency "__STATIC_CONTENT_MANIFEST": no matching module rules.
If you're trying to import an npm package, you'll need to bundle your Worker first

If I modify getServices to add a console.log, I can see that additionalModules is populated correctly:

[
  {
    name: '__STATIC_CONTENT_MANIFEST',
    text: '{"index.html":"$__MINIFLARE_SITES__$/index.html"}'
  }
]

However, it appears that the next line, invoking getWorkerScript, doesn't get this manifest and panics.

@ItalyPaleAle
Copy link
Author

Looks like loading the script using the modules array seems to make it work:

new Miniflare({
    host: options.address,
    port: parseInt(options.port, 10),
    workers: [
        {
            name: 'myapp',
            modules: [{
                type: 'ESModule',
                contents: script.toString('utf8'),
                path: 'index.mjs',
            }],
            compatibilityDate: '2023-05-18',
            sitePath: options.sitePath,
        },
    ],
})

@mrbbot
Copy link
Contributor

mrbbot commented Jul 17, 2023

Hey! 👋 This was raised by an internal user a couple weeks ago and it looks like a PR (#622) was put up to fix it, but closed. We should get that merged. 👍

@mrbbot
Copy link
Contributor

mrbbot commented Nov 7, 2023

Fixed by #631

@mrbbot mrbbot closed this as completed Nov 7, 2023
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