parcel-plugin-elm-symfony-bridge

Parcel plugin exposing symfony's translations and routing to elm.

Usage no npm install needed!

<script type="module">
  import parcelPluginElmSymfonyBridge from 'https://cdn.skypack.dev/parcel-plugin-elm-symfony-bridge';
</script>

README

elm-symfony-bridge

Build Status contributions welcome parcel plugin

Parcel plugin exposing symfony's translations and routing to elm.

Table of content

Quick Start

Translations are exposed using the Trans.<domain> module like following:

import Trans.Messages as Messages
import Trans.Security as Security

displayStuff : Html msg
displayStuff = 
    div [] [ text Messages.alert_awesome_plugin ]
    div [] [ text Security.global_must_have ]

The routing is exposed using the Routing module like following:

import Http
import Routing

makeHttpCall : Cmd msg
makeHttpCall =
    Http.send MsgGetThisPlugin <|
        Http.get Routing.app_get_this_plugin
            pluginDecoder

Installation

You can install the parcel plugin with npm:

npm install parcel-plugin-elm-symfony-bridge --save-dev

or with yarn:

yarn add parcel-plugin-elm-symfony-bridge --dev

And you're all done!

Configuration

This plugin follows parcel's zero-config philosophy and will automatically configure itself. You should be able to mostly ignore this section but if you really need to tweak something, here is the config along with the rules used to infer each value:

  • watch: Do we watch for changes to regenerate elm code? (defaults to parcel's own watch value)
  • watchFolders: Which folders to watch (defaults to src, app, config, translations)
  • watchExtensions: Which file extensions to watch (defaults to php, yaml, yml, xml)
  • watchConfig: Which files to watch for configuration changes (defaults to elm.json, elm-package.json, package.json, composer.json)
  • dev: Use symfony's env=dev or env=prod (defaults to parcel's own dev value)
  • generatedCodeFolder: Where to put generated code. Automatically added to your elm's source-directories config (defaults to elm-stuff/generated-code/elm-symfony-bridge)
  • tmpFolder: Where to put temporary (defaults to elm-stuff/generated-code/elm-symfony-bridge)
  • elmVersion: Elm version the generated code should be compatible with (defaults to 0.19 if a elm.json file is present, 0.18 if a elm-package.json file is present)
  • enableRouting: Enable generating routes (defaults to true)
  • urlPrefix: When dev is true, which prefix to use when generating urls (defaults to /index.php or /app_dev.php depending on which is found)
  • enableTranslations: Enable generating translations (defaults to true if the willdurand/js-translation-bundle package is installed)
  • lang: Lang to use when exporting translations (defaults to the default lang configured in symfony)

If these rules don't work for you, you can override any of these parameters in your package.json under the elm-symfony-bridge key like so:

{
  "elm-symfony-bridge": {
    "enableRouting": false,
    "lang": "fr"
  },
}

Usage

See Usage.

Versioning

elm-symfony-bridge follows semantic versioning. In short the scheme is MAJOR.MINOR.PATCH where

  1. MAJOR is bumped when there is a breaking change,
  2. MINOR is bumped when a new feature is added in a backward-compatible way,
  3. PATCH is bumped when a bug is fixed in a backward-compatible way.

Versions bellow 1.0.0 are considered experimental and breaking changes may occur at any time.

Contributing

Contributions are welcomed! There are many ways to contribute, and we appreciate all of them. Here are some of the major ones:

  • Bug Reports: While we strive for quality software, bugs can happen and we can't fix issues we're not aware of. So please report even if you're not sure about it or just want to ask a question. If anything the issue might indicate that the documentation can still be improved!
  • Feature Request: You have a use case not covered by the current api? Want to suggest a change or add something? We'd be glad to read about it and start a discussion to try to find the best possible solution.
  • Pull Request: Want to contribute code or documentation? We'd love that! If you need help to get started, GitHub as documentation on pull requests. We use the "fork and pull model" were contributors push changes to their personnal fork and then create pull requests to the main repository. Please make your pull requests against the master branch.

As a reminder, all contributors are expected to follow our Code of Conduct.

Hacking

The sources are organized in 3 main folders:

  • / the root contains the elm code: src for the sources and tests for the elm tests.
  • /webpack contains all the specifics for the webpack plugin.
  • /parcel contains all the specifics for the parcel plugin (you are here).

This project uses the following tools for development:

You'll find the following commands useful when hacking on this project (assuming you're at the root of the repository and this in this folder):

# build the package
npm run build

# run the tests and doc tests
npm run test

# Using a local build in a project using webpack
cd webpack && npm install && npm run build && npm pack # build a package.tgz
cd path/to/project/using/webpack                       # go in the root directory of your project
npm install path/to/package.tgz                        # install the locally built package

# Using a local build in a project using parcel
cd parcel && npm install && npm run build && npm pack # build a package.tgz
cd path/to/project/using/webpack                      # go in the root directory of your project
npm install path/to/package.tgz                       # install the locally built package

License

elm-symfony-bridge is distributed under the terms of the MIT license.

See LICENSE for details.