thgh / vercel-sapper

Vercel builder for Sapper with SSR enabled
MIT License
191 stars 25 forks source link

Warning: Entry module "src/server.js" is implicitly using "default" export mode #54

Closed zwergius closed 3 years ago

zwergius commented 4 years ago

Since updating sapper I've been getting this warning:

Entry module "src/server.js" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "src/server.js" to use named exports only.

thgh commented 4 years ago

Looks like you updated Rollup but not Sapper, the errors stems from rollup.config.js:

Solution see below

zwergius commented 4 years ago

Hi again,

I do have latest Sapper 0.28.3 and everything else updated to latest versions as well.

This warning appears when adding export default to "src/server.js" as described in the docs

TheSimpleZ commented 3 years ago

@thgh I don't understand if we're supposed to add "exports": "default" to the client object or as a param to the output() method. Either way doesn't seem to work, and I'm having the same issue as the others. Could you please re-open the issue?

thgh commented 3 years ago

It should be a property of the output object: https://rollupjs.org/guide/en/#outputexports

TheSimpleZ commented 3 years ago

I see.. Yeah, you're correct. Except it should be added to the output object under the server config, not the client. This seems to make the issue go away.

export default {
client: {...},
server: {
    input: config.server.input(),
    output: {...config.server.output(), exports: 'default'},
...
thgh commented 3 years ago

@TheSimpleZ Thanks for figuring it out, that makes way more sense 😛

Sidenote: another option is to write module.exports = instead of export default