Coder Social home page Coder Social logo

elm-brunch's People

Contributors

antonyshchenko avatar dustinfarris avatar fbonetti avatar igray avatar ilkosta avatar ivanoats avatar joakimk avatar john-goff avatar kevgathuku avatar madscoaducom avatar madsflensted avatar neildaemond avatar peeb avatar razzeee avatar ronanyeah avatar stelmakh avatar urfolomeus avatar voronchuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

elm-brunch's Issues

Request: 'merge' build strategy

Right now each module is compiled as separate file. In addition to that, it will be good to have the option to output all compiled modules as a single file.

New way to create Brunch plugins

It looks like there is a new template for creating Brunch plugins.

I discovered this when someone raised an issue on my SeatSaver repo. We were seeing strange behaviour when the elm file was in the watchlist, but everything worked fine when it wasn't. After a bit of poking around (and discussing with the fine folks on the Elixir Slack #phoenix channel) I realised that it was the latest release of Brunch (2.2.0) that had caused the issue and that the method for creating plugins had changed. I hacked out a quick spike to test and it seems to work fine on my environment (albeit much more simple and hardwired to my use case).

I'll hopefully have time to hack out a proper solution tomorrow evening if you like?

relative path executablePath

Problem

I'm trying to use executablePath in elm-brunch to run local installed elm.

The problem that I have this plugins fails to run elm-make

Elm compile: Main.elm, in elm, to ../static/vendor/main.js
/bin/sh: node_modules/elm/binwrappers/elm-make: No such file or directory
21:03:54 - error: Command failed: node_modules/elm/binwrappers/elm-make --yes --output ../static/vendor/main.js Main.elm

It does work if I make this change into index.js :

<       const executable = path.join(executablePath, 'elm-make');
---
>       const executable = process.cwd() + "/" + path.join(executablePath, 'elm-make');

Is it possible to check the executablePath and if it's relative path use this patch otherwise use it as it is? something like this :

<       const executable = path.join(executablePath, 'elm-make');
---
>       if(isRelativePath(executablePath)) {
>           const executable = process.cwd() + "/" + path.join(executablePath, 'elm-make');
>       } else {
>           const executable = path.join(executablePath, 'elm-make');
>       }

Information

  • elm-brunch version -> 0.8.0
  • brunch version -> 2.10.7
  • nodejs version -> v6.6.0
  • content of brunch-config.js
exports.config = {
  files: {
    javascripts: {
      joinTo: "js/app.js"
    },
    stylesheets: {
      joinTo: "css/app.css"
    },
    templates: {
      joinTo: "js/app.js"
    }
  },

  conventions: {
    assets: /^(static)/
  },

  // Phoenix paths configuration
  paths: {
    watched: ["static", "css", "js", "vendor", "elm"],
    public: "../priv/static"
  },

  // Configure your plugins
  plugins: {
    elmBrunch: {
      elmFolder: "elm",
      mainModules: ["Main.elm"],
      outputFolder: "../static/vendor",
      executablePath: './node_modules/elm/binwrappers'
    },
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/vendor/]
    }
  },

  modules: {
    autoRequire: {
      "js/app.js": ["js/app"]
    }
  },

  npm: {
    enabled: true
  }
};
  • content of elm-package.json
  • file layout for your elm files relative to root of project.
  • Operating System MacOS

Fails in minimal test case

Problem

(venv) soa@glaze:~/BloomcraftProcess/bloomcraft_process/budgeting/client$ brunch -v
2.10.9
(venv) soa@glaze:~/BloomcraftProcess/bloomcraft_process/budgeting/client$ brunch n elm_client
13:22:13 - log: Pulling recent changes from git repo "git://github.com/brunch/dead-simple.git" to "/home/soa/.brunch/skeletons/c76c330b8d54d134fca1e696f29bfc30993e5fd1"...
13:22:13 - log: Pulled master into "/home/soa/.brunch/skeletons/c76c330b8d54d134fca1e696f29bfc30993e5fd1"
13:22:13 - log: Copying local skeleton to "/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client"...
13:22:13 - log: Created skeleton directory layout
13:22:13 - info: Installing packages with npm...
cd elm_client
(venv) soa@glaze:~/BloomcraftProcess/bloomcraft_process/budgeting/client$ cd elm_client
(venv) soa@glaze:~/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client$ npm install --save-dev elm-brunch
[email protected] /home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client
└── [email protected] 

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]

Edit brunch-config.js here

(venv) soa@glaze:~/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client$ brunch w LOGGY_STACKS=1
/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/graceful-fs/polyfills.js:21
  chdir.call(process, d)
        ^

Error: ENOENT: no such file or directory, uv_chdir
  at Error (native)
  at process.chdir (/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/graceful-fs/polyfills.js:21:9)
  at Object.keys.reduce.Promise.all.then.setDefaultJobsCount.constructor.process.on.application.loadConfig.then.cfg.then.initCompilation.initWatcher.isConfig.watcher.chokidar.watch.on.error.on.compile.assetErrors.forEach.write.then.watch (/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/brunch/lib/watch.js:377:15)
  at exports.new.start (/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/brunch/lib/index.js:47:28)
  at Command.listener (/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/commander/index.js:301:8)
  at emitTwo (events.js:87:13)
  at Command.emit (events.js:172:7)
  at Command.parseArgs (/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/commander/index.js:615:12)
  at Command.parse (/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/commander/index.js:458:21)
  at Object.exports.run (/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/brunch/lib/cli.js:109:11)
  at Object.<anonymous> (/home/soa/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client/node_modules/brunch/lib/run-cli.js:3:18)
  at Module._compile (module.js:410:26)
  at Object.Module._extensions..js (module.js:417:10)
  at Module.load (module.js:344:32)
  at Function.Module._load (module.js:301:12)
  at Function.Module.runMain (module.js:442:10)
  at startup (node.js:136:18)
  at node.js:966:3

(venv) soa@glaze:~/BloomcraftProcess/bloomcraft_process/budgeting/client/elm_client$ 

My brunch-config.js is:

// See http://brunch.io for documentation.
exports.files = {
  javascripts: {joinTo: 'app.js'},
  stylesheets: {joinTo: 'app.css'}
};

exports.config.plugins: {
      elmBrunch: {
        // (required) Set to the elm file(s) containing your "main" function `elm make` 
        //            handles all elm dependencies relative to `elmFolder`
        mainModules: ['elm/Main.elm'],
      }
};

Information

  • [0.9.0 ] elm-brunch version
  • [2.10.9] brunch version
  • [4.2.6 ] nodejs version
  • [ see above] content of brunch-config.js
  • [ none] content of elm-package.json
  • [ none in this example] file layout for your elm files relative to root of project.
  • [ Ubuntu 16.04] Operating System

Compile multiple main modules to single js file

Problem: when specifying several modules with mainModules configuraiton, each output file will contain the entire elm core.

Solve by using elm makes ability to compile several top level modules into the same js file:

elm make MainA.elm MainB.elm MainC.elm --output main.js

Let this be a user option

brunch plugin build order

Problem

Hi! I'm experimenting an issue in a project, where I'm using elm-brunch along with babel-brunch. The issue is that elm-babel seems to be building first, and one of the js files is importing the main.js created by elm-brunch, which doesn't exist yet, so the build breaks due to not finding that file. I've tried arranging the npm modules to solve the build order issue, as specified in here brunch/brunch#1377 (comment), but it doesn't solve the problem. What can I do?

Information

  • elm-brunch version
    [email protected]

  • brunch version
    [email protected]

  • nodejs version
    v7.7.3

  • content of brunch-config.js
    exports.config = {
    // See http://brunch.io/#documentation for docs.
    files: {
    javascripts: {
    joinTo: {
    'js/app.min.js': /^(web/static/js|renderer)/,
    'js/vendor.min.js': /^(node_modules|elm)/,
    },

    // To use a separate vendor.js bundle, specify two files path
    // http://brunch.io/docs/config#-files-
    // joinTo: {
    //  "js/app.js": /^(web\/static\/js)/,
    //  "js/vendor.js": /^(web\/static\/vendor)|(deps)/
    // }
    //
    // To change the order of concatenation of files, explicitly mention here
    // order: {
    //   before: [
    //     "web/static/vendor/js/jquery-2.1.1.js",
    //     "web/static/vendor/js/bootstrap.min.js"
    //   ]
    // }
    

    },
    stylesheets: {
    joinTo: 'css/app.css',
    order: {
    after: ['web/static/css/app.scss'], // concat app.css last
    },
    },
    templates: {
    joinTo: 'js/app.js',
    },
    },

    conventions: {
    // This option sets where we should place non-css and non-js assets in.
    // By default, we set this to "/web/static/assets". Files in this directory
    // will be copied to paths.public, which is "priv/static" by default.
    assets: /^(web/static/assets)/,
    },

    // Phoenix paths configuration
    paths: {
    // Dependencies and current project directories to watch
    watched: [
    'elm',
    'renderer/client',
    'renderer/common',
    'web/static',
    'test/static',
    ],

    // Where to compile files to
    public: 'priv/static',
    },

    // Configure your plugins
    plugins: {
    elmBrunch: {
    elmFolder: 'elm',
    mainModules: ['src/Main.elm'],
    outputFolder: '../web/static/js',
    makeParameters: ['--debug'],
    },
    babel: {
    presets: ['es2015', 'react', 'stage-0'],
    plugins: ['transform-runtime'],
    // Do not use ES6 compiler in vendor code
    ignore: [/web/static/vendor/],
    },
    sass: {
    options: {
    includePaths: ['node_modules'],
    },
    },
    },

    modules: {
    autoRequire: {
    'js/app.min.js': ['web/static/js/app'],
    },
    },

    npm: {
    enabled: true,
    },
    };

  • content of elm-package.json
    {
    "version": "1.0.0",
    "summary": "helpful summary of your project, less than 80 characters",
    "repository": "https://github.com/user/project.git",
    "license": "BSD3",
    "source-directories": [
    "./src",
    "./vendor"
    ],
    "exposed-modules": [],
    "dependencies": {
    "NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
    "elm-community/list-extra": "6.0.0 <= v < 7.0.0",
    "elm-lang/core": "5.1.1 <= v < 6.0.0",
    "elm-lang/html": "2.0.0 <= v < 3.0.0",
    "elm-lang/websocket": "1.0.2 <= v < 2.0.0"
    },
    "elm-version": "0.18.0 <= v < 0.19.0"
    }

  • file layout for your elm files relative to root of project.

  • Operating System
    OSX El Capitan

Confused about configuration

Problem

Elm is compiling the file I just saved, rather than Main.elm where my main function resides. As a result I don't get the new functionality when I save (and have to switch the Main.elm and fake a save of that) and I'm getting files such as app.js.map in /priv/static/js

I've looked at the examples, but made no progress. Can you help?

Information

  • ["^0.7.0", ] elm-brunch version

  • ["2.7.4" ] brunch version

  • [6.7 ] nodejs version

  • [see below ] content of brunch-config.js

  • [ see below] content of elm-package.json

  • [web/elm ] file layout for your elm files relative to root of project.

  • [ Ubuntu 16.04] Operating System

    elmBrunch: {
    // Set to path where elm-make is located, relative to elmFolder (optional)
    // executablePath: '../../node_modules/elm/binwrappers',

    // Set to path where elm-package.json is located, defaults to project root (optional)
    // if your elm files are not in /app then make sure to configure paths.watched in main brunch config
    // elmFolder: '.',

    // Set to the elm file(s) containing your "main" function
    // elm make handles all elm dependencies (required)
    // relative to elmFolder
    mainModules: ['web/elm/Main.elm'],

    // Defaults to 'js/' folder in paths.public (optional)
    // outputFolder: 'some/path/',

    // If specified, all mainModules will be compiled to a single file (optional and merged with outputFolder)
    outputFile: 'main.js',

    // optional: add some parameters that are passed to elm-make
    makeParameters : ['--warn']
    },

{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"web/elm", "."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "5.0.0 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/http": "1.0.0 <= v < 2.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}

No color coding in terminal

Problem

When I run elm-brunch, I get monochromatic errors:

image

When I run elm-make directly, I get pretty errors:

image

Information

  • elm-brunch version 0.7.0
  • brunch version 2.8.2
  • nodejs version 6.3.0
  • content of brunch-config.js
exports.config = {
  sourceMaps: false,
  production: true,
  npm: {
    enabled: true
  },

  files: {
    // javascripts: {
    //   joinTo: 'thesis-editor.js'
    // },
    stylesheets: {
      joinTo: 'thesis.css'
    }
  },

  // Phoenix paths configuration
  paths: {
    // Which directories to watch
    watched: ['web/elm'],

    // Where to compile files to
    // public: 'priv/static'
  },

  modules: {
    autoRequire: {
      'thesis-editor.js': ['web/static/js/thesis-editor']
    }
  },

  // Configure your plugins
  plugins: {
    // babel: {
    //   // Do not use ES6 compiler in vendor code
    //   ignore: [/^(web\/static\/vendor)/],
    //   presets: ['es2015', 'react']
    // },
    elmBrunch: {
      mainModules: ['web/elm/Main.elm'],
      outputFolder: 'priv/js/',
      outputFile: 'thesis-editor.js'
    }
  }
}
  • content of elm-package.json
{
    "version": "0.0.21",
    "summary": "Thesis CMS - Content Management for Phoenix websites",
    "repository": "https://github.com/infinitered/thesis-phoenix.git",
    "license": "MIT",
    "source-directories": [
        "./web/elm"
    ],
    "exposed-modules": [],
    "dependencies": {
        "elm-lang/core": "4.0.5 <= v < 5.0.0",
        "elm-lang/html": "1.1.0 <= v < 2.0.0"
    },
    "elm-version": "0.17.1 <= v < 0.18.0"
}
  • file layout for your elm files relative to root of project. ./web/elm/Main.elm
  • Operating System Mac OS X

brunch build --production does not have a non-zero exit code on error

Problem

brunch build --production does not have a non-zero status code when there is an error in Elm code. If you on the other hand introduce an error in, say a JavaScript, it will return exit code 1.

This means our build server does not notice errors in Elm code. Which is bad :(

Information

  • [0.9.0 ] elm-brunch version
  • [2.10.10] brunch version
  • [v8.1.3] nodejs version
  • [Mac] Operating System

Feature Request: 'elmx' support

It would be highly convenient if elmx was supported via elm-brunch as currently there are no brunch plugins for elmx. The node library is just elmx and it is a very simple transpiler that converts react-like html structures in Elm code into the corresponding Elm.Html structure, thus giving back a normal .elm file. It is made to be fairly trivial to embed into build systems, however using bunch with no plugin for it yet means we have to do a manual compile step when we edit elmx files.

Race condition in brunch compile

I am having the elm-brunch plugin compile a variety of main apps into a single file, which is output to a brunch watched directory of other javascript, which then all gets compiled into one single javascript file. However brunch does not seem to pick up on Elm changes immediately as it seems to start compiling while Elm does and Elm finishes writing 'after' Brunch has already started compiling the files, so I have to save a file twice with ten seconds or so between them to have it compile twice.

Information

  • [0.6.0 ] elm-brunch version
  • [ 2.8.2] brunch version
  • [] nodejs version
  • content of brunch-config.js: Huge, but relevant parts are:
  plugins: {
    babel: {
      presets: ['es2015'],
      plugins: ["transform-object-rest-spread"],
      // Do not use ES6 compiler in vendor code
      ignore: [/web\/static\/vendor/],
      compact: false
    },
    elmBrunch: {
      elmFolder: '.',
      mainModules: [
        'web/elm/MessengerApp.elm',
        'web/elm/ExampleElmApp.elm'
      ],
      outputFolder: 'web/static/js',
      outputFile: 'elm.js',
      makeParameters: ['--warn']
    }
  },
  modules: {
    autoRequire: {
      "js/app.js": ["web/static/js/app"]
    }
  },
  paths: {
    watched: [
      "web/elm",
      "web/static",
      "test/static"
    ],

    public: "priv/static"
  },
  files: {
    javascripts: {
      joinTo: "js/app.js",
    },
    templates: {
      joinTo: "js/app.js"
    }
  },
  • content of elm-package.json:
{
  "version": "0.1.0",
  "summary": "Test",
  "repository": "https://github.com/user/project.git",
  "license": "BSD3",
  "source-directories": [
    "web/elm"
  ],
  "exposed-modules": [],
  "dependencies": {
    "elm-lang/core": "4.0.2 <= v < 5.0.0",
    "elm-lang/html": "1.1.0 <= v < 2.0.0",
  },
  "elm-version": "0.17.1 <= v < 0.18.0",
  • file layout for your elm files relative to root of project: elm-package.json is in the project root, elm files are in web/elm
  • Operating System - Windows 10 (it could very well be its filesystem at fault, and if so then it should sleep and test until it is finished saving until it lets brunch compile it all together).

Unexpected end of input

Using version 0.3.1, brunch can't compile any elm files:

iex(1)> Elm compile: Main.elm, in web/elm, to ../static/vendor/main.js
27 Sep 17:34:26 - error: Compiling of 'web/static/vendor/main.js' failed. Line 777: Unexpected end of input

After downgrading to 0.3.0, the problem goes away. This is with elm 2.0.0, Linux 3.16.0-37.

main.elm:

module Main where

import Html exposing(..)

main = text "sup"

Elm has no issue compiling it with elm-make.

Elm 0.19

Are you planning an update for Elm 0.19? Or do you accept a patch for this?

Request: option to use use local elm binary

This is more of a request than an issue. It occurred to me that seeing as you can now install the elm command line tool via npm, that you could install a project-specific version of elm and run from node_modules/bin/elm instead of elm. This would allow you specify elm as a project dependency and also lock to a particular version if need be.

With this being the case elm-brunch would need to be able to either take an option that would specify the elm binary command to run, or that would check first for a local elm and default to global if a local not found.

What do you think? I don't mind adding this feature if you think it is worthwhile.

Can't compile Elm file

Problem

image

Information

  • elm-brunch version - 0.12.0
  • brunch version - 2.10.17
  • nodejs version - 10.15.0
  • content of brunch-config.js
// See http://brunch.io for documentation.
module.exports = {
  files: {
    javascripts: {
      joinTo: {
        'libraries.js': /^(?!app\/)/,
        'app.js': /^app\//,
      },
    },
    stylesheets: { joinTo: 'app.css' },
  },
  plugins: {
    elmBrunch: {
      mainModules: 'app/elm/Main.elm',
    },
  },
};
  • content of elm.json (Elm 0.19)
{
  "type": "application",
  "source-directories": ["app/elm"],
  "elm-version": "0.19.0",
  "dependencies": {
    "direct": {
      "elm/browser": "1.0.1",
      "elm/core": "1.0.2",
      "elm/html": "1.0.0"
    },
    "indirect": {
      "elm/json": "1.1.3",
      "elm/time": "1.0.0",
      "elm/url": "1.0.0",
      "elm/virtual-dom": "1.0.2"
    }
  },
  "test-dependencies": {
    "direct": {},
    "indirect": {}
  }
}
  • file layout for your elm files relative to root of project.
    image

  • Operating System - MacOS HighSierra

Failing elm-make on 0.11.0 for a config that works on 0.10.0

Problem

Using the same brunch configuration for an app running phoenix+elm, with one version using elm-brunch 0.10.0 and the other using 0.11.0, the following error always occurs on 0.11.0:

$ mix phx.server
...
Elm compile: Main.elm, in elm, to ../vendor/main.js
...
elm-make: Main.elm: openFile: does not exist (No such file or directory)

There is no error on the 0.10.0 version. However, the output is slightly different. The elm-compile line looks like:

Elm compile: src/Main.elm, in elm, to ../vendor/main.js

It seems as though the 0.11.0 version cannot locate the Main.elm file in the src folder. The relevant section of brunch-config.js is given below, as well as the elm files, relative to the root (the assets folder).

Possible cause

It seems as though this issue is related to a slight change in the index.js file, where the function call to elmCompile now receives a path.basename(src) as opposed to just the src, even if the independentModules flag is false.

Information

  • [0.11.0] elm-brunch version
  • [2.10.9 ] brunch version
  • [9.3.0] nodejs version

brunch-config.js (same for the 0.10.0 and 0.11.0 versions)

elmBrunch: {
  elmFolder: "elm",
  mainModules: ["src/Main.elm"],
  outputFolder: "../vendor"
}

File layout:

assets
  elm
    src
      Main.elm
    elm-package.json
  brunch-config.js
  • [macOS - latest] Operating System

not possible to join or uglify

I have the problem that elm-brunch directly compiles to files in the destination folder. So brunch can't join the compiled elm files with other javascripts files, nor is it possible to uglify.

Other brunch plugins, like coffescript-brunch returns the content of compiled file to the callback instead of directly writing to the destination folder.

Do you have any idea to solve the problem ?

elm-brunch watch --server gets out of sync

Problem

Since 0.10.0 elm-brunch somehow gets out of sync with the files on disk. This results in elm-brunch --watch reporting compile errors even after the issues have been resolved.

I don't have a small isolated example. But I will try explaining the symptoms:

While working on the project and changing some things, I introduce a compile error. Most of the time, the elm-brunch is happy after having corrected the compile error. But quite often maybe like 1 of 20 times, elm-brunch gets stuck on a compile issue and will continue to report it even after the issue has been resolved.

Workaround: Restart brunch, everything compiles.

Possible causes:

  1. Our project is one of the worlds larges ~60kloc Elm code bases and the issue may be some race condition that only happens when there are many files.
  2. We are using atom-elm-make which will compile the code on save and show compile errors in the IDE. This could be conflicting with the elm-make instance that elm-brunch is executing. I know there have been recent issues in the atom-elm-make github issues where multiple elm-make instances would run simultaneously. That has since been resolved.
  3. Brunch is somehow caching old files or not noticing the changes to the files to update the cache.

Please let me know how I can provide more information. This does not occur with webpack.
I will try elm-brunch 0.7.0 and report back with my findings.

Information

  • [0.10.0] elm-brunch version
  • [2.10.10] brunch version
  • [v8.1.3] nodejs version
  • [app/elm/] file layout for your elm files relative to root of project.
  • [MacOs] Operating System

Multiple elm-package.json files

Problem

I have a project with a structure similar to the following:

    elm    
        details    
            Details.elm
            elm-package.json
        list
            ObjectList.elm
            elm-package.json

Each module has a different list of dependencies. How would you recommend using elm-brunch to build a project that can have multiple elm-package.json files?

Information

  • elm-brunch version
  • brunch version
  • nodejs version
  • content of brunch-config.js
  • content of elm-package.json
  • file layout for your elm files relative to root of project.
  • Operating System

Error running elm-brunch

I'm getting the following error starting Brunch watch --server

error: Compiling of src\justCompile.elm failed. Invalid regular expression: /^src[\]?/: Unterminated character class

The regex seems to be tied settings from brunch-config.json file specifically the "elmFolder" property.
When the elmFolder is set to elmFolder: "src", then the error appears as above. However when it is omitted then the error switches to.

error: Compiling of src\justCompile.elm failed. Invalid regular expression: /^null[\]?/: Unterminated character class

[TypeError: Cannot read property 'split' of undefined]

My ELM code (https://github.com/puruzio/seat_saver) works fine in Elm Reactor, and compiles well with elm-make, but when I compile it through elm-brunch, I get the following error. This doesn't give me much clue as to where to fix the error.

My-MacBook-Pro:seat_saver_old puruzio$ brunch build
Elm compile: Main.elm, in web/elm, to ../static/vendor/main.js
[BABEL] Note: The code generator has deoptimised the styling of "web/elm/app.js" as it exceeds the max of "100KB".
[BABEL] Note: The code generator has deoptimised the styling of "web/elm/elm.js" as it exceeds the max of "100KB".
05 Mar 16:16:51 - info: compiling
05 Mar 16:16:54 - error: [TypeError: Cannot read property 'split' of undefined]

My project is based on the example found here http://www.cultivatehq.com/posts/phoenix-elm-10/ to which I am attempting to add multiple modules in separate files.

Problem with initial file compilation on Windows

Problem

On windows it seems as if, after cloning a repo, the elm files are not compiled. Only after changing the contents of every elm file, then saving each file, does elm-brunch recognize the change in the file and compiles the elm file to a js file.

Mac OSX and Linux (Ubuntu 15) work fine. The problem only happens on Windows. I have reproduced this on two different Windows workstations.

Repo:
https://github.com/svard/hello_phoenix

The problem with reproducing this issue with this repo is, the project is a phoenix/Elixir project with Elm as the frontend rendering tool. If you need to reproduce the problem with the above repo, it is relatively straightforward:

Install chocolatey

choco install erlang -y
choco install elixir -y

In the projects root folder:

mix deps.get
npm install
mix phoenix.server

The Elm file is in the folder

web\static\elm

The compiled js file is written to the folder

priv\static\js

Hope this is enough information regarding this issue.

Regards

Rudolf Bargholz

Information

  • elm-brunch version

0.4.4

  • brunch version

2.5.2

  • nodejs version

5.9.0

  • content of brunch-config.js
exports.config = {
  // See http://brunch.io/#documentation for docs.
  files: {
    javascripts: {
      joinTo: "js/app.js"

      // To use a separate vendor.js bundle, specify two files path
      // https://github.com/brunch/brunch/blob/stable/docs/config.md#files
      // joinTo: {
      //  "js/app.js": /^(web\/static\/js)/,
      //  "js/vendor.js": /^(web\/static\/vendor)|(deps)/
      // }
      //
      // To change the order of concatenation of files, explicitly mention here
      // https://github.com/brunch/brunch/tree/master/docs#concatenation
      // order: {
      //   before: [
      //     "web/static/vendor/js/jquery-2.1.1.js",
      //     "web/static/vendor/js/bootstrap.min.js"
      //   ]
      // }
    },
    stylesheets: {
      joinTo: "css/app.css"
    },
    templates: {
      joinTo: "js/app.js"
    }
  },

  conventions: {
    // This option sets where we should place non-css and non-js assets in.
    // By default, we set this to "/web/static/assets". Files in this directory
    // will be copied to `paths.public`, which is "priv/static" by default.
    assets: /^(web\/static\/assets)/
  },

  // Phoenix paths configuration
  paths: {
    // Dependencies and current project directories to watch
    watched: [
      "web/static",
      "test/static"
    ],

    // Where to compile files to
    public: "priv/static"
  },

  // Configure your plugins
  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/web\/static\/vendor/]
    },
    elmBrunch: {
      mainModules: ["web/static/elm/Chat.elm"]
    }
  },

  modules: {
    autoRequire: {
      "js/app.js": ["web/static/js/app"]
    }
  },

  npm: {
    enabled: true,
    // Whitelist the npm deps to be pulled in as front-end assets.
    // All other deps in package.json will be excluded from the bundle.
    whitelist: ["phoenix", "phoenix_html"]
  }
};
  • content of elm-package.json
{

  "version": "1.0.0",
  "summary": "helpful summary of your project, less than 80 characters",
  "repository": "https://github.com/user/project.git",
  "license": "BSD3",
  "source-directories": [
    "web/static/elm"
  ],
  "exposed-modules": [],
  "dependencies": {
    "elm-lang/core": "3.0.0 <= v < 4.0.0",
    "evancz/elm-effects": "2.0.1 <= v < 3.0.0",
    "evancz/elm-html": "4.0.2 <= v < 5.0.0",
    "evancz/start-app": "2.0.2 <= v < 3.0.0",
    "svard/elm-phoenix": "2.0.0 <= v < 3.0.0"
  },
  "elm-version": "0.16.0 <= v < 0.17.0"
}
  • file layout for your elm files relative to root of project.

/web/static/elm/

  • Operating System

Windows 10

Chain compilation failed

I think that vendor/*.js compilation started before elm make had finished writing *.js file.

To demonstrate it follow this:

  1. clone https://github.com/urfolomeus/seat_saver.git
  2. npm install
  3. node_modules/brunch/bin/brunch watch --stdin
  4. seat_saver/web/elm$ touch SeatSaver.elm

Observe sporadically failure to compile.
<<
~/tmp/seat_saver$ node_modules/brunch/bin/brunch watch --stdin master
Elm compile: SeatSaver.elm, in web/elm, to ../static/vendor/seatsaver.js
12 Oct 12:56:09 - info: compiled 5 files into 2 files, copied 4 in 15392ms
Elm compile: SeatSaver.elm, in web/elm, to ../static/vendor/seatsaver.js
12 Oct 12:56:19 - error: Compiling of 'web/static/vendor/seatsaver.js' failed. Line 75: Unexpected end of input
Elm compile: SeatSaver.elm, in web/elm, to ../static/vendor/seatsaver.js
12 Oct 12:56:20 - info: compiled seatsaver.js and 2 cached files into app.js in 271ms
Elm compile: SeatSaver.elm, in web/elm, to ../static/vendor/seatsaver.js
END

Reproduced on Debian 7,
$ uname -a
Linux leonis 3.16.0-4-686-pae #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) i686 GNU/Linux
$ node -v
v4.0.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.