Hi, I am trying this plugin for the first time. And I am having an issue that this plugin is not been called by the rollup config.
The error that I am getting is
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/elm/HelloWorld.elm (1:7)
1: module HelloWorld exposing (main)
^
2:
3: import Html exposing (Html, text)
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
Please see below for my setup detail.
Here is my /rollup.config.js
file
import {terser} from 'rollup-plugin-terser';
import html from '@web/rollup-plugin-html';
import sass from 'rollup-plugin-sass';
import path from 'path'
import elm from 'rollup-plugin-elm'
const production = !process.env.ROLLUP_WATCH;
export default [
{
input: 'src/sass/main.scss',
output: [{file: 'dist/css/bundle.js'}],
plugins: [sass({output: true})]
},
{
input: 'src/js/main.js',
output: [
{
file: 'dist/js/bundle.js',
format: 'cjs',
plugins: [elm({
exclude: 'elm_stuff/**',
pathToElm: path.resolve(__dirname, 'node_modules/elm/bin/elm')
})]
},
{
file: 'dist/js/bundle.min.js',
format: 'iife',
name: 'version',
plugins: [terser(),elm({
exclude: 'elm_stuff/**',
pathToElm: path.resolve(__dirname, 'node_modules/elm/bin/elm')
})]
}
]
},
{
input: 'src/index.html',
output: [
{
dir: 'dist'
}
],
plugins: [
// add HTML plugin
html({
minify: true,
extractAssets: false
}),
]
}
];
Here is my /src/js/main.js
import Elm from '../elm/HelloWorld.elm'
Elm.HelloWorld.init({
node: document.getElementById('main')
})
Here is my /src/elm/Helloworld.elm
module HelloWorld exposing (main)
import Html exposing (Html, text)
main : Html msg
main =
Html.text "Hello, World!"
Here is my /elm.json
{
"type": "application",
"source-directories": [
"src/elm"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"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": {}
}
}
Here is my /package.json
file
{
"dependencies": {
"@web/dev-server": "^0.1.17",
"@web/rollup-plugin-html": "^1.7.0",
"bulma": "^0.9.2",
"concurrently": "^6.2.0",
"elm": "^0.19.1-5",
"rollup": "^2.47.0",
"rollup-plugin-elm": "^3.0.0",
"rollup-plugin-sass": "^1.2.2",
"rollup-plugin-terser": "^7.0.2"
},
"scripts": {
"build": "rollup --config",
"start": "concurrently --kill-others --names rollup,web-dev-server \"rollup -w --config\" \"web-dev-server\""
}
}
Please help recommend how to debug the error that I am facing. From what I see it looks like this plugin is not been called eventhough I have added as instructed on the README.