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

Refactor module to run in the browser #12

Open
sebamarynissen opened this issue Dec 7, 2022 · 1 comment
Open

Refactor module to run in the browser #12

sebamarynissen opened this issue Dec 7, 2022 · 1 comment
Assignees
Labels
feature General discussion & musings about a certain feature

Comments

@sebamarynissen
Copy link
Owner

We're currently transforming www.growifier.com to be a static website, meaning that we no longer need a server for it. In order to be able to do this though, this module needs to be able to run in browser as well when used with webpack.

@sebamarynissen sebamarynissen added the feature General discussion & musings about a certain feature label Dec 7, 2022
@sebamarynissen sebamarynissen self-assigned this Dec 7, 2022
sebamarynissen added a commit that referenced this issue Dec 7, 2022
See #12. In order to avoid accessing the file system *at runtime*, we no longer parse the exemplar properties at runtime, but by using a compile step to json which we then load at runtime instead.
sebamarynissen added a commit that referenced this issue Dec 7, 2022
See #12. We've refactored the module a bit more so it can now be bundled with webpack, at least that's what we hope, lol.
@sebamarynissen
Copy link
Owner Author

sebamarynissen commented Dec 7, 2022

Cool, we've tested a basic webpack setup

// # webpack.config.js
const path = require('path');

module.exports = {
  mode: 'development',
  devtool: false,
  entry: './main.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'main.js',
  },
  resolve: {
    fallback: {
      util: false,
      path: false,
      fs: false,
      crypto: false,
      buffer: require.resolve('buffer/'),
    },
  },
};

and it looks like it's working. It's a bit quick and dirty, but at least we should be able to use it in growifier now, which is our main priority now!

Not that ideally packing for the browser works without any webpack polyfills, but we really can't get around polyfilling the buffer module unfortunately. Oh well.

sebamarynissen added a commit that referenced this issue Dec 7, 2022
See #12. We no longer include the `new_properties.xml` file in the npm module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature General discussion & musings about a certain feature
Projects
None yet
Development

No branches or pull requests

1 participant