vite-plugin-elm icon indicating copy to clipboard operation
vite-plugin-elm copied to clipboard

Use elm binary selectively

Open hmsk opened this issue 5 years ago • 8 comments

  1. node_modules
  2. global
  3. give through config

hmsk avatar Mar 23 '21 04:03 hmsk

Would this be an additional config option possibly to be able to pass in pathToElm directly node-elm-compiler? If so I'd be happy to make a PR. I know I'll be wanting to use https://github.com/mdgriffith/elm-optimize-level-2 soon-ish for my project.

wolfadex avatar Jan 20 '22 01:01 wolfadex

Definitely that was what I intended for 3 but wondering some fancy ways to pick elm binary.

Like if a project which uses this package has elm via npm should pick that automatically and just use elm (env global) for otherwise. config.pathToElm can overwrite them forcibly.

Feel free to submit a PR to enable pathToElm config (then pass down into node-el-compiler. Thanks!

hmsk avatar Jan 23 '22 23:01 hmsk

Cool, I'm testing this out locally for a bit to make sure I'm not breaking anything. I'll make a PR once I feel it's working well.

wolfadex avatar Feb 06 '22 23:02 wolfadex

@wolfadex I’m evaluating Vite as a build framework. Could you find a way to use elm-optimize-level-2 for production builds?

laurentpayot avatar May 04 '22 08:05 laurentpayot

I did but need to refactor my approach and have been distracted by non-code things recently.

After my initial attempt, elm-optimize-level-2 made a change to allow running with a make command which should allow it to be used with node-elm-compiler.

wolfadex avatar May 04 '22 12:05 wolfadex

I'm just considering managing compilers within this plugin then get rid of node-elm-compiler since this plugin is not fully using their features. We should be able to spawn a compiler by ourselves. In the same time, I expect to accept elm-optimize-level-2 could be easier. Only the concern is HMR stuff and asset handlings should be rewritten for elm-optimize-level-2 (have you looked around?).

Anyways, will be back after #217 is closed.

hmsk avatar May 04 '22 18:05 hmsk

Any news regarding this? 😄 As I already include different dependencies in my index.js, I like to also include Elm as a dependency. It also makes it easier for other developers who is new to Elm to get right into development instead of setup. Thus, it would be great for me to be able to specify pathToElm as a config!

johanneskvamme avatar Sep 28 '22 13:09 johanneskvamme

Now that v2.9.0-beta.1 accepts raw options for node-elm-compiler via nodeElmCompilerOptions it is finally possible to use elm-optimize-level-2! :tada:

elmPlugin({
  optimize: false, // no `--optimize` option when using elm-optimize-level-2
  nodeElmCompilerOptions: {
    pathToElm: process.env.NODE_ENV === 'production' ? 'node_modules/elm-optimize-level-2/bin/elm-optimize-level-2' : undefined
  }
})

You may get depreciation warnings as described in https://github.com/mdgriffith/elm-optimize-level-2/issues/104.

laurentpayot avatar May 04 '23 09:05 laurentpayot