Skip to content

Compatibility with modernizr-server #27

@rlindskog

Description

@rlindskog

Hi,

I just made some middleware to handle fetching modernizr information to the server. It's called modernizr-server. Do you think its possible to change the wrapOutput function while targetting node to something like this? Not to experience with building webpack loaders.

function wrapOutput(output) {
    // Exposing Modernizr as a module.
    return ";(function(global){\n" +
         "var hadGlobal = 'Modernizr' in global;\n" +
         "var oldGlobal = global.Modernizr;\n" +
         "global.Modernizr = `" + output + "`\n" +
         "module.exports = global.Modernizr;\n" +
         "if (hadGlobal) { global.Modernizr = oldGlobal; }\n" +
         "else { delete global.Modernizr; }\n" +
    "})(global);";
}

This would just make expose the modernizr build as a string that modernizr-server would send to the client to be executed.

It would work with modernizr-server like this.

app.use(modernizrServer({
  build: Modernizr
}))

app.get('/', function(req, res) {
  let Moderizr = req.cookies.modernizr
}

see modernizr-server for more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions