language: node_js
node_js:
  - "lts/*"
  - "node"
env:
  # we current only test "use strict" for our NPM builds
  - BUILD=node TEST_STRICT_BUNDLE=1
  - BUILD=browser
  - BUILD=browser NO_MINIFY=1
script:
  - |
    export BUILD_PARAMS="-t $BUILD"

    if [ "x$NO_MINIFY" = "x1" ]; then
      export BUILD_PARAMS="$BUILD_PARAMS -n"
    fi

    node tools/build.js $BUILD_PARAMS

    # test that our build is "use strict" safe for use with packaging
    # systems importing our source thru ES6 modules (rollup, etc.)
    if [ "x$TEST_STRICT_BUNDLE" = "x1" ]; then
      ./node_modules/.bin/rollup -c test/builds/rollup_import_via_commonjs.js
      node build/bundle.js || exit 1
      rm build/bundle.js
    fi

    if [ "x$BUILD" = "xnode" ]; then
      npm run test
    else
      npm run test-browser || exit 1
      # our browser build should also work fine as a Node.js CommonJS module
      node test/builds/browser_build_as_commonjs.js
    fi
sudo: false  # Use container-based architecture