npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ct-mapapps-browser-sync

v0.0.42

Published

A support lib for mapapps projects using browser-sync.

Downloads

453

Readme

ct-mapapps-browser-sync

A support lib for browser-sync as development server.

Features:

  • Middleware components for:
    • js-registry /resources/jsregistry/root
      • scan of src folders
      • scan of registry .jar files
      • scan of registry .zip files
      • scan bundles from npm_modules folder
    • Allow of json comments in manifest.json files
    • Filtering of @@key@@ expressions
    • Markdown to html support via js-registry
    • proxy forwards, e.g. /proxy?http://myserver.de/arcgis/rest/services

Usage

Within gulpfile.js call:

const gulp = require("gulp");
const mapappsBrowserSync = require("ct-mapapps-browser-sync");

const options = {};
mapappsBrowserSync.registerTask(options, gulp);

// after that the new task "browser-sync", "browser-sync-start" and "browser-sync-stop" are available

// e.g. special watch goal:

gulp.task("srv-watch",
    gulp.parallel(
        "watch",
        "browser-sync"
    ));

Configuration

The following shows possible options, and the default values:

{
    // default, directories, served by browsersync
    directories : ["./target/webapp", "./target/test-classes"],

    // reload is handled externally
    externalReloadTrigger: false,

    // looks for changes in the directories and reloads the browsers automatically
    watchChanges: true

    // next free is used, note if the port is already used, it is incremented automatically, to the next free.
    port: undefined,

    // activate https protocol, generates a self signed certificate for "localhost"
    https: false,

    // opens the browser if true
    urlToOpen: true,

    // false will disable the browser sync ui for additional features
    ui: undefined,

    // configuration of properties filtering
    // configuration options are read from all directories from the file 'application.properties'
    properties: {
        // Specifies path regex matchers, where @@key@@ expressions should be filtered
        // Default paths matches see /src/propertiesfilter.js
        paths: [
            /^\/sample.html$/
        ],
        config: {
            // Key-value pairs of mapapps properties, e.g.
            // "esri.api.arcgisPortalUrl": "https://dev0303w.conterra.de/portal"
        }
    },
    json: {
        // by default comments are stripped from json
        stripComments : true, 
        // would enable support of jsonp, e.g x.json?callback=method
        jsonpSupport : false 
    },
    jsreg: {
         // folder from where the bundle jars are imported
        importFolder = "target/bundle-imports/",
        // src folder from where local bundles are imported
        srcFolder = "target/webapp/js",
        // url where the srcFolder is served
        srcWebBase = "/js",
        // glob patterns to ignore in srcFolder
        // e.g. ignorePattern: ["**/sample/**"],
        ignorePattern = [],
        // modules directly imported from npm_modules folder
        // see section "modules from npm"
        npmModules = [],
        // location of npm directory
        // default is node_modules from which this lib is imported.
        // e.g:
        npmDir : __dirname + "/node_modules/",
    },
    // additional references to custom middleware files
    // e.g. middleware: [__dirname + "/src/test/js/myMiddleware.js"]
    middleware: []
}

NPM Modules as bundles

The config option jsreg.npmModules allows the import of custom bundles from NPM into the jsregistry middleware. Note the bundles or javascript files, need to support AMD or UMD, to be loaded into the browser.

This shows a concrete sample, how this feature can be used. The imported modules, need to be listed as devDependencies in the package.json.

jsreg: {
    npmModules: [
        [
            "chai",
            {
                // need to overwrite to ensure import "chai" is working
                main: "chai"
            }
        ],
        "mocha",
        "@conterra/mapapps-mocha-runner",
        [
            "@vue/test-utils",
            {
                // need to overwrite main to load it into the browser
                main: "dist/vue-test-utils.umd"
            }
        ],
        // required as peer dependency of @vue/test-utils
        "vue-template-compiler"
    ]
}

Custom middleware

The config option middleware allows the registration of additional middleware scripts. See browser-sync docu.

Note you need to list custom middleware as scripts, e.g. middleware: [__dirname + "/src/test/js/myMiddleware.js"]. This is required because the DevServer is started in a custom Worker-Thread to be independent of additional gulp tasks.