Giter VIP home page Giter VIP logo

cli-build-app's Introduction

@dojo/cli-build-app

Build Status Build status codecov npm version

The official CLI command for building optimized Dojo applications.

Usage

To use @dojo/cli-build-app in a single project, install the package:

npm install @dojo/cli-build-app

Features

@dojo/cli-build-app is a command for the @dojo/cli.

Building

There are four modes available to build a Dojo application, dist, dev, unit, and functional. The mode required can be passed using the --mode flag:

dojo build app --mode dist

The built application files are written to the output/{dist/dev} directory. The built test files are written to the output/test/{unit|functionl} directory.

Note: dist is the default mode and so can be run without any arguments, dojo build app.

Dist Mode (default)

The dist mode creates a production-ready build.

Bundle Analyzer

When building your application in dist mode, the build process will generate a webpack bundle analyzer that can be used to inspect the content of your application's bundles. The webpack bundle analyzer is outputted to the output/info/analyzer directory of your project. To view the analyzer, open the index.html file contained in this directory.

webpack bundle analyzer

Dev mode

The dev mode creates an application build that has been optimized for debugging and development.

Unit mode

The unit mode creates bundles that can be used to run the unit tests of the application.

Functional mode

The functional mode creates bundles that can be used to run the functional tests of the application.

Polyfills

The build command conditionally loads polyfills from @dojo/framework/shim based on your application's usage and the user's browser capabilities.

Legacy Browser Support

By default, the build will support the last two versions of the latest browsers. To support IE 11, run the build with the --legacy (-l) flag.

Asset Management

While most assets will be imported by modules in the src/ directory and therefore handled by the main build pipeline, it is often necessary to serve static assets or include assets in the HTML file itself (e.g., the favicon).

Static assets can be added to an assets/ directory at the project root. At build time, these assets are copied as-is without file hashing to output/{mode}/assets, and can be accessed using the absolute /assets/ path. For example, if users need access to a static terms of service document named terms.pdf, that file would added to assets/terms.pdf and accessed via the URL /assets/terms.pdf.

The build also parses src/index.html for CSS, JavaScript, and image assets, hashing them and including them in the output/{mode}/ directory. For example, it is common for applications to display a favicon in the URL bar. If the favicon is named favicon.ico, it can be added to the src/ directory and included in src/index.html with <link rel="icon" href="favicon.ico">. The build will then hash the file and copy it to output/{mode}/favicon.[hash].ico.

Code Splitting By Route

The build command will automatically code split your application based on its dojo routing configuration.

To enable the code automatic splitting by route:

  1. The dojo routing configuration needs to be the default export from a routes.ts module in the src directory.
  2. Widgets must by the default export of their module.
  3. When defining the Outlet, the renderer function must be defined inline.
// routes.ts
export default [
	{
		path: 'foo',
		outlet: 'foo',
		children: [
			{
				path: 'bar',
				outlet: 'bar'
			}
		]
	},
	{
		path: 'bar',
		outlet: 'bar'
	}
];
// widget
import WidgetBase from '@dojo/framework/widget-core/WidgetBase';
import { v, w } from '@dojo/framework/widget-core/d';
import Outlet from '@dojo/framework/routing/Outlet';

import FooWidget from './FooWidget';
import BarWidget from './BarWidget';

export default class App extends WidgetBase {
	protected render() {
		return v('div', [
			w(Outlet, { id: 'foo', renderer: () => w(FooWidget, {})}),
			w(Outlet, { id: 'bar', renderer: () => w(BarWidget, {})})
		]);
	}
}

The output will result in a separate bundle for each of the application's top level routes. In this example, there will be a main application bundle and two further bundles for src/FooWidget and src/BarWidget.

Note: The configuration can be further refined using the bundle configuration in the .dojorc, see bundles configuration.

Serving the Application

A web server can be started with the --serve flag while running in dev or dist modes. By default, the application is served on port 9999, but this can be changed with the --port (-p) flag:

# build once and then serve the app on port 3000
dojo build -s -p 3000

By default, the files will be served via HTTP. HTTPS can be enabled by placing server.crt and server.key files in a .cert directory in the root of your project:

|-- my-project
    |-- .cert
        |-- .server.crt
        |-- .server.key

When these files are detected, dojo build -s will automatically serve files via HTTPS.

Proxy Configuration

The development server can be configured to act as a simple proxy. Add a proxy section to your .dojorc containing the paths you want to proxy. The key of the object is the path you want to proxy and the value of the object is the proxy configuration.

{
    "build-app": {
        "proxy": {
            "/api": {
                "target": "http://example.com",
                "changeOrigin": true,
                "pathRewrite": {
                    "^/api": "/api/v1"
                }
            },
            "/simple": "http://example.com"
        }
    }
}

Proxy configuration can take the following options:

Property Description
target The source URL to proxy from
changeOrigin true to rewrite the origin header (required for named based virtual hosts)
ws true to proxy WebSockets
pathRewrite key/value pairs of paths that will get rewritten during the proxy. The key is a regular expression to be matched, the value is the replacement.

Note: Setting the proxy configuration as a string is equivelant to { target: "string" }.

Watching

Building with the --watch option observes the file system for changes and when with the development server (--serve) will automatically reload you browser.

# start a build with watch
dojo build --mode=dev --watch

# start a build using the development server and live reload
dojo build --mode=dev --serve --watch

Eject

Ejecting @dojo/cli-build-app will produce the following files under the config/build-app directory:

  • build-options.json: the build-specific config options removed from the .dojorc
  • ejected.config.js: the root webpack config that passes the build options to the appropriate mode-specific config based on the --env.mode flag's value.
  • base.config.js: a common configuration used by the mode-specific configs.
  • base.test.config.js: a common configuration used by the unit and functional modes.
  • dev.config.js: the configuration used during development.
  • dist.config.js: the production configuration.
  • unit.config.js: the configuration used when running unit tests.
  • functional.config.js: the configuration used when running functional tests.

As already noted, the dojorc's build-app options are moved to config/build-app/build-options.json after ejecting. Further, the modes are specified using webpack's env flag (e.g., --env.mode=dev), defaulting to dist. You can run a build using webpack with:

node_modules/.bin/webpack --config=config/build-app/ejected.config.js --env.mode={dev|dist|unit|functional}

Configuration

Applications use a .dojorc file at the project root to control various aspects of development such as testing and building. This file, if provided, MUST be valid JSON, and the following options can be used beneath the "build-app" key:

bundles: object

Useful for breaking an application into smaller bundles, the bundles option is a map of webpack bundle names to arrays of modules that should be bundled together. For example, with the following configuration, both src/Foo and src/Bar will be grouped in the foo.[hash].js bundle.

Widget modules defined used with w() will be automatically converted to a lazily imported, local registry item in the parent widget. This provides a mechanism for declarative code splitting in your application.

{
	"build-app": {
		"bundles": {
			"foo": [
				"src/Foo",
				"src/Bar"
			]
		}
	}
}

The bundles configuration supports globs for matching against modules, this can be useful for scenarios such as grouping all nls internationalization modules by locale:

{
	"build-app": {
		"bundles": {
			"fr": [
				"src/**/nls/fr/**"
			],
			"de": [
				"src/**/nls/de/**"
			]
		}
	}
}

Note: The precedence for bundle configuration is 1) An exact match wins against a glob match 2) Order based with the last config winning.

cldrPaths: string[]

An array of paths to CLDR JSON files. Used in conjunction with the locale and supportedLocales options (see below). If a path contains the string {locale}, that file will be loaded for each locale listed in the locale and supportedLocales properties. For example, with the following configuration the numbers.json file will be loaded for the "en", "es", and "fr" locales:

{
	"build-app": {
		"locale": "en",
		"supportedLocales": [ "es", "fr" ]
		"cldrPaths": [
			"cldr-data/main/{locale}/numbers.json"
		]
	}
}

compression: Array<'gzip' | 'brotli'>

Options for compression when running in dist mode. Each array value represents a different algorithm, allowing both gzip and brotli builds to be output side-by-side. When used in conjunction with the --serve flag (in dist mode without memory watch), the compressed files will be served, with brotli preferred over gzip when available.

imageOptimization: boolean | object

If this is set to true, image optimization will be performed when running in dist mode using default settings. This uses several different libraries depending on the type of image being optimized. imageOptimization can be an object with individual configuration for these libraries in nested objects. They can also be individually disabled by passing { enabled: false }. Webp optimization is disabled by default and can be enabled by passing webp: { enabled true }. The options available for each library can be found at the links below:

externals: object

Non-modular libraries or standalone applications that cannot be bundled normally can be included in a Dojo application by providing an implementation of require or define when needed, and some configuration in the project's .dojorc file.

Configuration for external dependencies can be provided under the externals property of the build-app config. externals is an object with two allowed properties:

  • outputPath: An optional property specifying an output path to which files should be copied.

  • dependencies: A required array that defines which modules should be loaded via the external loader, and what files should be included in the build. Each entry can be one of two types:

    • A string that indicates that this path, and any children of this path, should be loaded via the external loader.
    • An object that provides additional configuration for dependencies that need to be copied into the built application. This object has the following properties:
Property Type optional Description
from string false A path relative to the root of the project specifying the location of the files or folders to copy into the build application.
to string true A path that replaces from as the location to copy this dependency to. By default, dependencies will be copied to ${externalsOutputPath}/${to} or ${externalsOutputPath}/${from} if to is not specified. If there are any . characters in the path and it is a directory, it needs to end with a forward slash.
name string true Either the module id or the name of the global variable referenced in the application source.
inject string, string[], or boolean true This property indicates that this dependency defines, or includes, scripts or stylesheets that should be loaded on the page. If inject is set to true, then the file at the location specified by to or from will be loaded on the page. If this dependency is a folder, then inject can be set to a string or array of strings to define one or more files to inject. Each path in inject should be relative to ${externalsOutputPath}/${to} or ${externalsOutputPath}/${from} depending on whether to was provided.
type 'root' or 'umd' or 'amd' or 'commonjs' or 'commonjs2' true Force this module to a specific method of resolution. For AMD style require use umd or amd. For node style require use commonjs, and to access the object as a global use root

As an example the following configuration will inject src/legacy/layer.js into the application page, inject the file that defines the MyGlobal global variable, declare that modules a and b are external and should be delegated to the external layer, and then copy the folder node_modules/legacy-dep, from which several files are injected. All of these files will be copied into the externals folder, which could be overridden by specifying the outputPath property in the externals configuration.

"externals": {
	"dependencies": [
		"a",
		"b",
		{ "from": "node_modules/GlobalLibrary.js", "to": "GlobalLibrary.js", "name": "MyGlobal", "inject": true },
		{ "from": "src/legacy/layer.js", "to": "legacy/layer.js", "inject": true },
		{
			"from": "node_modules/legacy-dep",
			"to": "legacy-dep/",
			"inject": [ "moduleA/layer.js", "moduleA/layer.css", "moduleB/layer.js" ]
		}
	]
}

Types for any dependencies included in externals can be installed in node_modules/@types, like any other dependency.

Because these files are external to the main build, no versioning or hashing will be performed on files in a production build, with the exception of the links to any injected assets. The to property can be used to specify a versioned directory to copy dependencies to in order to avoid different versions of files being cached.

features: object

A map of has features to boolean flags that can be used when building in dist mode to remove unneeded imports or conditional branches. See the static-build-loader documentation for more information.

locale: string

The default locale for the application. When the application loads, the root locale is set to the user's locale if it supported (see below), or to the default locale as a fallback.

pwa: object

A parent map that houses settings specific to creating progressive web applications.

pwa.manifest: object

Specifies information for a web app manifest. If provided, the following <meta> tags are injected into the application's index.html:

  • mobile-web-app-capable="yes": indicates to Chrome on Android that the application can be added to the user's homescreen.
  • apple-mobile-web-app-capable="yes": indicates to iOS devices that the application can be added to the user's homescreen.
  • apple-mobile-web-app-status-bar-style="default": indicates to iOS devices that the status bar should use the default appearance.
  • apple-touch-icon="{{icon}}": the equivalent of the manifests' icons since iOS does not currently read icons from the manifest. A separate meta tag is injected for each entry in the icons array.

For example:

{
	"build-app": {
		"pwa": {
			"manifest": {
				"name": "Todo MVC",
				"description": "A simple to-do application created with Dojo",
				"icons": [
					{ "src": "./favicon-16x16.png", "sizes": "16x16", "type": "image/png" },
					{ "src": "./favicon-32x32.png", "sizes": "32x32", "type": "image/png" },
					{ "src": "./favicon-48x48.png", "sizes": "48x48", "type": "image/png" },
					{ "src": "./favicon-256x256.png", "sizes": "256x256", "type": "image/png" }
				]
			}
		}
	}
}

pwa.serviceWorker: object

Generates a fully-functional service worker that is activated on startup, complete with precaching and custom route handling. Alternatively, you can create your own service worker file and @dojo/cli-build-app will ensure it is copied to the correct output directory. Under the hood, the ServicerWorkerPlugin from @dojo/webpack-contrib is used to generate the service worker, and all of its options are valid pwa.serviceWorker properties. Note that if pwa.serviceWorker.cachePrefix is not included, it defaults to the name property from the application's package.json.

{
	"build-app": {
		"pwa": {
			"serviceWorker": {
				"cachePrefix": "my-app",

				// exclude the "admin" bundle from caching
				"excludeBundles": [ "admin" ],

				"routes": [
					// Use the cache-first strategy for loading images, adding them to the "my-app-images" cache.
					// Only the first ten images should be cached, and for one week.
					{
						"urlPattern": ".*\\.(png|jpg|gif|svg)",
						"strategy": "cacheFirst",
						"cacheName": "my-app-images",
						"expiration": { "maxEntries": 10, "maxAgeSeconds": 604800 }
					},

					// Use the cache-first strategy to cache up to 25 articles that expire after one day.
					{
						"urlPattern": "http://my-app-url.com/api/articles",
						"strategy": "cacheFirst",
						"expiration": { "maxEntries": 25, "maxAgeSeconds": 86400 }
					}
				]
			}
		}
	}
}

build-time-render(BTR): object

Renders the application to HTML during the build and in-lines the critical CSS. This allows the application to effectively render static HTML pages and provide some advantages of SSR (server side rendering) such as performance, SEO etc without the complexities of running a server to support full SSR.

  • root (required) : The id of the root DOM node that application merge onto.
  • paths (optional): An array of routes for rendering the application during the build; for more complex routes an object can be provided with a basic "matcher" (regular expression) that gets used to match against the application's route on page load.

Build time rendering supports applications that use either the @dojo/framework/routing/history/HashHistory or @dojo/framework/routing/history/StateHistory history managers. If your application uses the HashHistory, ensure that all paths are prefixed with a # character.

{
	"build-app": {
		"build-time-render": {
			"root": "app",
			"paths": [
				"#home",
				{
					"path": "#comments/9999",
					"match": [ "#comments\/.*" ]
				}
			]
		}
	}
}

BTR generates a screenshot for each of the paths rendered during the build in the output/info/screenshots directory of your project.

Build time rendering exposes a has flag build-time-render that can be used to skip functionality that cannot be executed at build time, for example fetching external data.

if (!has('build-time-render')) {
	fetch( /* ... */ );
}

Note: The index.html of your application needs to contain a DOM node with the id specified as the root in the configuration. This DOM node needs to be used when mounting the renderer for application:

const r = renderer(() => w(YourAppWidget, {}));
r.mount({ domNode: document.getElementById('app')! });

supportedLocales: string[]

An array of supported locales beyond the default. When the application loads, the user's locale is checked against the list of supported locales. If the user's locale is compatible with the supported locales, then the user's locale is used throughout the application. Otherwise, the default locale is used. For example, with the following configuration, the application locale will be set to Pashto or Arabic if either is listed as the user's locale, with Farsi used as the default.

Example:

{
	"build-app": {
		"locale": "fa",
		"supportedLocales": [ "ps", "ar" ],
		"compression": "gzip",
		"bundles": {
			"widgets": [
				"src/widgets/Header",
				"src/widgets/Footer"
			]
		}
	}
}

How do I contribute?

We appreciate your interest! Please see the Dojo Meta Repository for the Contributing Guidelines. This repository uses prettier for code style and is configured with a pre-commit hook to automatically fix formatting issues on staged .ts files before performing the commit. If you are changing the .dojorc configuration behaviour for build-app, please make sure to update the schema.json (a JSON Schema description which is used to validate the build-app configuration) to match the changes.

Installation

To start working with this package, clone the repository and run:

npm install

In order to build the project, you can run all the build steps via:

npm run build

Scripts

watch

Will run a watcher process which looks for changes in the source code TypeScript files and runs the build scripts to update the contents of the built files in dist with latest changes made.

clean

Runs the clean up script which removes any built files like output, dist, coverage which get created on build and testing steps.

lint

Runs the ts-lint and prettier on all .ts files in the src and tests directories. ts-lint will ensure that all linting rules have been abided by and prettier will fix any detected code style violations in the code.

Testing

Test cases MUST be written using Intern using the BDD test interface and Assert assertion interface.

90% branch coverage MUST be provided for all code submitted to this repository, as reported by istanbul’s combined coverage results for all supported platforms.

The command is tested by running via the Dojo CLI and asserting the build output against known fixtures. To do this, a test artifact needs to be built and installed into the test-app:

npm test

Licensing information

© 2018 JS Foundation. New BSD license.

cli-build-app's People

Contributors

aciccarello avatar agubler avatar bryanforbes avatar devpaul avatar dylans avatar jameslmilner avatar jamesvhays avatar kanefreeman avatar maier49 avatar matt-gadd avatar mwistrand avatar nicknisi avatar rorticus avatar tomdye avatar willstott101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

cli-build-app's Issues

Upgrade to Webpack 4

As the title says, upgrade to webpack 4. May need changes in webpack-contrib.

Using `--serve` in test mode does not serve the test runner

Enhancement

At the moment using the --serve option when building in test mode is pretty useless as it serves the output/test directory meaning that it does not enable running the tests in the browser.

We should consider serving from the project root or disabling --serve when building the tests.

Optimise our CSS output

We should consider using https://github.com/NMFR/optimize-css-assets-webpack-plugin to optimise our css output. This is especially important if we enable css-variables because otherwise there is a lot of duplication in the output css (because most widget css files import variables.css).

The main issue previously is that using this plugin breaks our sourcemaps. We need to find the correct / appropriate properties to get this working correctly.

Enables: #62

Possibility to change webpack dev-server configuration

@evra commented on Thu Nov 09 2017

Enhancement

Package Version: 0.2.1-pre

It would be very helpfull to have a possibility to change default webpack dev server configuration - https://github.com/webpack/webpack-dev-server

One of the usecases would be a possibility to configure REST api proxy parameters (see for example: https://github.com/webpack/webpack-dev-server/blob/master/examples/proxy-simple/webpack.config.js) or use the history api.


@kitsonk commented on Wed Nov 29 2017

Thanks for the feedback!

Agreed that it might be a good thing to provide some level of access to control the development server to make it easier to fit wider use cases.

We are currently re-writing the build tool for Beta 5.

Requiring uncompiled `.m.css` files from outside `src` / `test` does not work with current webpack config

Current webpack config is set up to load and process local (src / test) .m.css files, or load pre-built .m.css files from @dojo/widgets etc.

Moving themes as uncompiled .m.css files under node_modules/@dojo/themes breaks the assumptions about if a .m.css file is compiled or not.

We should change our approach to determining if a .m.css file is built to detecting if there is a .m.css.js or .m.css.json file alongside it. If this exists, then we know it is built, if it does not exist, then we should pass it through our post-css module loader.

Enables: dojo/widgets#426

Enable css-variables in our builds

As per https://caniuse.com/#feat=css-variables css-variables are now supported in most modern browsers but we compute there values and remove the actual variables from our css.

We should look to leave these in for compatible browsers via static build flags.

Worth noting that when preserving css-variables, the built output is bullet-proofed for older browsers. ie.

if you have --red: #ff0000; and use it on a class selector, the built output is .className: { color: #ff0000; color: var(--red); } so that the browser that does not understand the var function can fall back to the hex value.

Improve terminal output

Had some ideas for potential improvements for the development build output. Also I should say, I'm of the mindset of keeping terminal output from developer tooling very minimal. It's something ava does well.

Here's a screenshot from my terminal output, with one linting error:

image

If for example I omit a semi colon from a line of JavaScript, I see:

✖ errors: 2
⚠ warnings: 0

errors:
./src/main.ts
Module build failed: Error: Compilation failed due to tslint errors.
    at report (/Users/umarhansa/development/dojo-devtool-todomvc/app/node_modules/tslint-loader/index.js:93:11)
    at lint (/Users/umarhansa/development/dojo-devtool-todomvc/app/node_modules/tslint-loader/index.js:74:3)
    at Object.module.exports (/Users/umarhansa/development/dojo-devtool-todomvc/app/node_modules/tslint-loader/index.js:140:3)
@ multi ./src/main.css ./src/main.ts,./src/main.ts
[15, 32]: Missing semicolon

@ multi ./src/main.css ./src/main.ts
  1. Errors shows '2' but there is only one.
  2. If warnings is '0' I don't see any need in showing that label
  3. Module build failed: Error: Compilation failed due to tslint errors. I don't think a linter should prevent the build, since I feel it's normal during development to not adhere to linting rules, but still want to see the webpage in your browser. Maybe the build could fail, but can still build the assets so it can be viewed?
errors:
./src/main.ts
Module build failed: Error: Compilation failed due to tslint errors.

I feel this output can be kept minimal, for example, could that whole section be replaced with:

Compilation failed due to tslint errors.
  1. The stack trace is quite distracting (long line length, and red):
    at report (/Users/umarhansa/development/dojo-devtool-todomvc/app/node_modules/tslint-loader/index.js:93:11)
    at lint (/Users/umarhansa/development/dojo-devtool-todomvc/app/node_modules/tslint-loader/index.js:74:3)
    at Object.module.exports (/Users/umarhansa/development/dojo-devtool-todomvc/app/node_modules/tslint-loader/index.js:140:3)

Maybe we could hide it?

  1. The main tslint issue:
@ multi ./src/main.css ./src/main.ts,./src/main.ts
[15, 32]: Missing semicolon

@ multi ./src/main.css ./src/main.ts

I feel the '@' symbols are redundant, don't think the word 'multi' needs to be there? And it's confusing to figure out what file contains the error!

  1. The asset output:
chunks:
main     runtime
assets:
index.html (0.36kb) / (0.25kb gz)                                             main.8d59fede549628a868e4.bundle.js (141.46kb) / (36.74kb gz)                 runtime.d41d8cd98f00b204e980.bundle.js (1.73kb) / (0.97kb gz)
main.0d78d4c854229f19f2fe03e6ab78d9f8.bundle.css (6.50kb) / (1.93kb gz)       main.8d59fede549628a868e4.bundle.js.map (551.18kb) / (140.68kb gz)            runtime.d41d8cd98f00b204e980.bundle.js.map (7.85kb) / (2.69kb gz)
main.0d78d4c854229f19f2fe03e6ab78d9f8.bundle.css.map (10.50kb) / (2.59kb gz)  manifest.json (0.38kb) / (0.16kb gz)
output at: file:////Users/umarhansa/development/dojo-devtool-todomvc/app/output/dist

Not sure it's necessary to see all of this info? For example seeing manifest.json (0.38kb) / (0.16kb gz) is not useful? Same with source map files. Maybe a verbose flag for all that info is better?

  1. Hash
ℹ cli-build-app: 0.0.1
ℹ typescript: 2.6.2
✔ hash: cdcde3fc9ce6dcf2d5f4
✖ errors: 2
⚠ warnings: 0

Not sure the hash is useful to see?

dojo build command throws error on Node 10

When running dojo build, Node throws the following error with both build commands (app and widget).

node[54537]: ../src/node_file.cc:829:void node::fs::Stat(const FunctionCallbackInfo<v8::Value> &): Assertion `(argc) == (3)' failed.
 1: node::Abort() [/usr/local/bin/node]
 2: node::Assert(char const* const (*) [4]) [/usr/local/bin/node]
 3: node::fs::LStat(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
 4: v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/bin/node]
 5: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
 6: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
 7: 0xe60c938427d

tslint configuration does not accept `linterOptions - exclude`

If I add a section like

{ ... "linterOptions": { "exclude": [ "**/generated/product-rest.ts", "**/*.css.d.ts" ] } }

the given typescript files will be still be processed by the dojo build.

If I use this tslint.json when I run tslint from the command line this works.

Work with packages installed using pnpm

dojo build fails if packages are installed with pnpm rather than npm.

To reporoduce:

  1. download first Dojo 2 tutorial
  2. pnpm install -g @dojo/cli
  3. cd 001_static_content/initial/biz-e-corp
  4. pnpm install
  5. dojo build --mode dev --watch memory --serve

Fails with error like

Commands are not available: Error: Failed to load module /home/rob/tmp/001_static_content/initial/biz-e-corp/node_modules/@dojo/cli-build-app
Nested error: Cannot find module 'webpack'

Tested against

  • Dojo 2.0 RC2
  • @dojo/cli 0.6.2
  • @dojo/cli-build-app 0.3.5
  • pnpm 1.40.2

Enable support for extending Webpack config

The Problem
Right now we have 2 options to use the cli-build:

  • either take the config as is, 100%
  • eject the whole config and support later changes on our own.

The Goal
Using the Default config but extending small options with our own Webpack config object

Advantages
You could specify small things such as additional loaders, other postCSS Settings etc without ejecting the while project. If you just want to fine-tune a few objects there is no need to extract the full configuration.

The Solution
There is already a package that pretty much does exactly what I would want to do. Could this be implemented? Would solve a lot of pain in the... escape key.

Allow serving over SSL

Eventually we should allow dojo build -s to accept an SSL key and certificate so that, for example, third-party services that require a secure connection could be used in local development.

Favour .mjs for evergreen builds

We currently ship .mjs along with our normal .js umd distributions. For evergreen we should consider using the .mjs modules as they are not transpiled down to ES5 by TS which in theory should result in smaller overall bundle size and better native performance.

`dojo build --serve` doesn't work on Windows

When trying the "serve" option in Windows 10, the build process would just stop after the server runs. Specifically, I was running:

dojo build -w -s

The project builds, and then it says "Listening on xyz" and I'm back to the command prompt.

Issue with debugging CSS classes

@sebilasse commented on Sat Mar 17 2018

When I dojo build -m dev -w memory -s and look in the browser console to debug a CSS class I noticed that all classes from different CSS files show the same CSS file as source. This seems to be the first stylesheet loaded.

E.g. in this screenshot the rule does not come from tab-controller.m.css (as indicated) but from toolbar.m.css

bildschirmfoto 2018-03-17 um 11 20 09


@agubler commented on Sat Mar 17 2018

@sebilasse Hmmm that is really strange as it seems to worked as expected on Chrome, Firefox, Edge - however on Safari it isn't mapping back to the source CSS. Seems like it could be an issue with safari rather than the CSS sourcemaps given it works across those other browsers.

I'll move the issue over to @dojo/cli-build-app for further discussion

Bundle Analyser is not working

The bundles analyser output in the info directory is not working. The pages are throwing errors when they are opened.

CSS vs. POSTCSS sources

We use different tools for testing code quality. Most of these tools use the file extension to determine the file type. Unfortunately the "*.m.css" files are post css files and sometimes the scanners fail.

Would it be possible to change the file extension of css to "pcss" so that IDEs, static code analysis tools (...) can recognize the file type by the extension?

(I hope that this issue is not completely wrong here - sorry if ...)

Configure GitHub issue and PR templates

The other Dojo 2 repositories provide default templates for new GitHub issues and pull requests, helping to ensure that every issue or PR meets a minimum set of requirements. We should add those templates to cli-build-app as well.

Unable to serve the app

If I run dojo build, it works well, but if I run dojo build -s -p 9999 to serve the app, I see it hangs. I tried with two versions of cli-build-app, I tried the master branch and also the latest published NPM version.

Here are my current versions :

dojo version

The currently installed groups are:

build (@dojo/cli-build-app) 0.1.0
create (@dojo/cli-create-app) 0.2.1
test (@dojo/cli-test-intern) 0.2.1

You are currently running @dojo/cli 0.2.0

The app I tried this in is one created with dojo create app -n testing. Also ran rm -rf node_modules/@dojo/cli-build-webpack before continuing.

Implement eject

Implement eject for the webpack configs. We need to work out a way to handle inlining/exporting the .dojorc also (which cli-build-webpack never did)

Ship evergreen builds by default

At the moment we have to specifically target an evergreen browser to get a build that elides a lot of stuff that is now in all browsers - apart from IE11. We should flip this so we ship an evergreen bundle by default, and offer a legacy flag to build for IE11.

Enable `ignoreOrder` option for `extract-text-webpack-plugin`

Bug

The bug is described pretty well in
webpack-contrib/extract-text-webpack-plugin#386

Package Version: latest

Actual behavior:
dojo build -m dev -w memory -s
->
Order in extracted chunk undefined

"Interestingly, it's not deterministic." ff. :
webpack-contrib/extract-text-webpack-plugin#80 (comment) (same here)

There is an ignoreOrder flag documented here
https://github.com/webpack-contrib/extract-text-webpack-plugin#options

I'd recommend to switch it on in base.config.js – it solved the problem for me …

Report postcss warnings

Our build process stubs out console.log so we do not show the warnings coming from the postcss process. We should look into how we can report these warnings.

Improving the basic web server

Currently, running dojo build -s just starts a web server that blindly serves the output directory for the current mode (e.g., /output/dev). However, this does not work for --mode=test as there are only two files there (functional.js and unit.js), and does not allow anything but the hash router to be used in other modes.

For dev and dist modes, one solution is to serve all extension-less routes from / and continue delivering assets (JS, CSS, HTML, images) statically. For test mode, we could attempt to serve node_modules/intern/index.html, but I am inclined to think that running tests is the purview of @dojo/cli-test-intern and that --serve should be disabled in test mode.

Sometimes out of sync CSS modules

Bug

This occurred with cli-build-webpack but it has started occurring for me with cli-build-app as well. Sometimes when adding new classes to a CSS Module, the type definitions are not generated in time for the TypeScript compile to complete and I will get red herrings on dojo build and have to repeat the build to clear the error. For example when adding some classes and immediately used them in a widget I got the following:

errors:
./src/widgets/StoreTravel.ts
[tsl] ERROR in /Users/kitsonk/github/devtool/src/widgets/StoreTravel.ts(34,50)
      TS2339: Property 'timeline' does not exist on type 'typeof "/Users/kitsonk/github/devtool/src/widgets/styles/storetravel.m.css"'.,./src/widge
ts/StoreTravel.ts
[tsl] ERROR in /Users/kitsonk/github/devtool/src/widgets/StoreTravel.ts(35,51)
      TS2339: Property 'slider' does not exist on type 'typeof "/Users/kitsonk/github/devtool/src/widgets/styles/storetravel.m.css"'.

When performing a subsequent dojo build without any further changes, the errors were no longer present.

In memory dev watch mode

We should consider supporting an in memory based watch mode using webpack-dev-middleware. This would allow us to have live reload and show errors in the browser. We should enable this for dev only as production likely has parts that are file dependent, and it makes no sense for test as we require physical files.

Startup output

Enhancement

Currently, when running dojo build there is no initial output. That can give the user a concern/pause wondering if the build is working.

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.