Giter VIP home page Giter VIP logo

chrome-scalajs-template's Issues

sbt test fails with `Error: Cannot find module './scalajs.webpack.config'`

If I clone the project and run sbt test I get:

[info] Fast optimizing /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/chrome-scalajs-template-test-fastopt
[info] Writing and bundling the test loader
[error] /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/cli.js:74
[error] 				throw err;
[error] 				^
[error] Error: Cannot find module './scalajs.webpack.config'
[error] Require stack:
[error] - /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/dev.webpack.config.js
[error] - /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/utils/convert-argv.js
[error] - /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/cli.js
[error] - /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack/bin/webpack.js
[error]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
[error]     at Function.Module._load (internal/modules/cjs/loader.js:667:27)
[error]     at Module.require (internal/modules/cjs/loader.js:887:19)
[error]     at require (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
[error]     at Object.<anonymous> (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/dev.webpack.config.js:3:18)
[error]     at Module._compile (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
[error]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
[error]     at Module.load (internal/modules/cjs/loader.js:863:32)
[error]     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
[error]     at Module.require (internal/modules/cjs/loader.js:887:19)
[error]     at require (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
[error]     at WEBPACK_OPTIONS (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/utils/convert-argv.js:115:13)
[error]     at requireConfig (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/utils/convert-argv.js:117:6)
[error]     at /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/utils/convert-argv.js:124:17
[error]     at Array.forEach (<anonymous>)
[error]     at module.exports (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/utils/convert-argv.js:122:15)
[error]     at /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/cli.js:71:45
[error]     at Object.parse (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/yargs/yargs.js:567:18)
[error]     at /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/cli.js:49:8
[error]     at Object.<anonymous> (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/cli.js:375:3)
[error]     at Module._compile (internal/modules/cjs/loader.js:999:30)
[error]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
[error]     at Module.load (internal/modules/cjs/loader.js:863:32)
[error]     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
[error]     at Module.require (internal/modules/cjs/loader.js:887:19)
[error]     at require (internal/modules/cjs/helpers.js:74:18)
[error]     at Object.<anonymous> (/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack/bin/webpack.js:80:2)
[error]     at Module._compile (internal/modules/cjs/loader.js:999:30)
[error]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
[error]     at Module.load (internal/modules/cjs/loader.js:863:32) {
[error]   code: 'MODULE_NOT_FOUND',
[error]   requireStack: [
[error]     '/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/dev.webpack.config.js',
[error]     '/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/utils/convert-argv.js',
[error]     '/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack-cli/bin/cli.js',
[error] Failure on parsing the output of webpack: No content to map due to end-of-input
[error]     '/home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack/bin/webpack.js'
[error]  at [Source: (ProcessPipeInputStream); line: 1, column: 0]
[error]   ]
[error] }
[error] You can try to manually execute the command
[error] node /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/node_modules/webpack/bin/webpack --bail --profile --json --mode development --config /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/dev.webpack.config.js /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/chrome-scalajs-template-test-fastopt-loader.js --output /home/lcampos/Development/chrome-scalajs-template/target/scala-2.13/scalajs-bundler/test/chrome-scalajs-template-test-fastopt-bundle.js
[error] 
[error] stack trace is suppressed; run last Test / jsEnvInput for the full output
[error] (Test / jsEnvInput) Non-zero exit code: 1
[error] Total time: 202 s (03:22), completed 21/02/2021, 08:36:02

State of the Storage API

I wanted to dabble a bit with browser storage and recalled that I have seen some template code for this. One search later, I arrived at:

def load(): Future[Option[Long]] = {
  chrome.storage.Storage.local
    // .get(key)
    .get(???) // TODO: Fix
    .map(_.asInstanceOf[js.Dictionary[String]])
    .map { dict =>
      val json = dict.getOrElse(StorageKey, "{}")
      parse(json).toOption
        .flatMap(_.as[Json].toOption)
        .flatMap(_.hcursor.downField("lastUsedOn").as[Long].toOption)
    }
}

I can't promise to take a crack at this, since using local storage would be, in my case, a bit of a workaround in itself, but I thought I'd ask you @AlexITC if you happened to have a working version. I certainly would not mind if it found its way into the template ;)

Thanks for this template!

I can tell a lot of work went into this and I doubt I would have had the patience to figure all of this out by myself from 0, so thanks!

Add tests

For any sane project, tests are mandatory, which gets a bit tricky in Scala.js browser extensions, let's add examples so that our users do not need to figure everything by themselves.

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.