aurelia-loader-webpack

  • Version 2.2.4
  • Published
  • 138 kB
  • 4 dependencies
  • MIT license

Install

npm i aurelia-loader-webpack
yarn add aurelia-loader-webpack
pnpm add aurelia-loader-webpack

Overview

An implementation of Aurelia's loader interface to enable webpack.

Index

Functions

function ensureOriginOnExports

ensureOriginOnExports: (moduleExports: any, moduleId: string) => any;

    Classes

    class TextTemplateLoader

    class TextTemplateLoader {}
    • An implementation of the TemplateLoader interface implemented with text-based loading.

    method loadTemplate

    loadTemplate: (loader: any, entry: any) => Promise<void>;
    • Loads a template.

      Parameter loader

      The loader that is requesting the template load.

      Parameter entry

      The TemplateRegistryEntry to load and populate with a template. A promise which resolves when the TemplateRegistryEntry is loaded with a template.

    class WebpackLoader

    class WebpackLoader extends Loader {}
    • A default implementation of the Loader abstraction which works with webpack (extended common-js style).

    constructor

    constructor();

      property hmrContext

      hmrContext: {
      handleModuleChange(moduleId: string, hot: WebpackHotModule): Promise<void>;
      handleViewChange(moduleId: string): Promise<void>;
      };

        property loaderPlugins

        loaderPlugins: { [name: string]: any };

          property moduleRegistry

          moduleRegistry: any;

            property modulesBeingLoaded

            modulesBeingLoaded: Map<string, Promise<any>>;

              property templateLoader

              templateLoader: TextTemplateLoader;

                method addPlugin

                addPlugin: (pluginName: string, implementation: any) => void;
                • Registers a plugin with the loader.

                  Parameter pluginName

                  The name of the plugin.

                  Parameter implementation

                  The plugin implementation.

                method applyPluginToUrl

                applyPluginToUrl: (url: string, pluginName: string) => string;
                • Alters a module id so that it includes a plugin loader.

                  Parameter url

                  The url of the module to load.

                  Parameter pluginName

                  The plugin to apply to the module id. The plugin-based module id.

                method loadAllModules

                loadAllModules: (ids: Array<string>) => Promise<any[]>;
                • Loads a collection of modules.

                  Parameter ids

                  The set of module ids to load. A Promise for an array of loaded modules.

                method loadModule

                loadModule: (moduleId: string, defaultHMR?: boolean) => Promise<any>;
                • Loads a module.

                  Parameter moduleId

                  The module ID to load. A Promise for the loaded module.

                method loadTemplate

                loadTemplate: (url: string) => Promise<any>;
                • Loads a template.

                  Parameter url

                  The url of the template to load. A Promise for a TemplateRegistryEntry containing the template.

                method loadText

                loadText: (url: string) => Promise<any>;
                • Loads a text-based resource.

                  Parameter url

                  The url of the text file to load. A Promise for text content.

                method map

                map: (id: string, source: any) => void;
                • Maps a module id to a source.

                  Parameter id

                  The module id.

                  Parameter source

                  The source to map the module to.

                method normalize

                normalize: (moduleId: string, relativeTo: string) => Promise<string>;
                • Normalizes a module id.

                  Parameter moduleId

                  The module id to normalize.

                  Parameter relativeTo

                  What the module id should be normalized relative to. The normalized module id.

                method normalizeSync

                normalizeSync: (moduleId: string, relativeTo: string) => string;
                • Normalizes a module id.

                  Parameter moduleId

                  The module id to normalize.

                  Parameter relativeTo

                  What the module id should be normalized relative to. The normalized module id.

                method useTemplateLoader

                useTemplateLoader: (templateLoader: TextTemplateLoader) => void;
                • Instructs the loader to use a specific TemplateLoader instance for loading templates

                  Parameter templateLoader

                  The instance of TemplateLoader to use for loading templates.

                Interfaces

                interface HotOptions

                interface HotOptions {}

                  property ignoreUnaccepted

                  ignoreUnaccepted?: boolean;
                  • If true the update process continues even if some modules are not accepted (and would bubble to the entry point).

                  interface WebpackHotModule

                  interface WebpackHotModule {}

                    property data

                    data?: any;
                    • Data from the previous version of this module, if set and disposed using the dispose() handler.

                    method accept

                    accept: {
                    (
                    dependencies: string[],
                    callback: (updatedDependencies: Array<string>) => void
                    ): void;
                    (dependency: string, callback: () => void): void;
                    (errHandler?: (e: Error) => void): void;
                    };
                    • Accept code updates for the specified dependencies. The callback is called when dependencies were replaced.

                    • Accept code updates for this module without notification of parents. This should only be used if the module doesn’t export anything. The errHandler can be used to handle errors that occur while loading the updated module.

                    method addDisposeHandler

                    addDisposeHandler: (callback: (data: any) => void) => void;
                    • Add a one time handler, which is executed when the current module code is replaced. Here you should destroy/remove any persistent resource you have claimed/created. If you want to transfer state to the new module, add it to data object. The data will be available at module.hot.data on the new module.

                    method addStatusHandler

                    addStatusHandler: (callback: (status: HotModuleStatus) => void) => void;
                    • Register a callback on status change.

                    method apply

                    apply: {
                    (
                    options: HotOptions,
                    callback: (err: Error, outdatedModules: any[]) => void
                    ): void;
                    (callback: (err: Error, outdatedModules: any[]) => void): void;
                    };
                    • Continue the update process. If status() != "ready" it throws an error.

                    method check

                    check: {
                    (
                    autoApply: boolean,
                    callback: (err: Error, outdatedModules: any[]) => void
                    ): void;
                    (callback: (err: Error, outdatedModules: NodeModule[]) => void): void;
                    };
                    • Throws an exceptions if status() is not idle. Check all currently loaded modules for updates and apply updates if found. If no update was found, the callback is called with null. If autoApply is truthy the callback will be called with all modules that were disposed. apply() is automatically called with autoApply as options parameter. If autoApply is not set the callback will be called with all modules that will be disposed on apply().

                    • Throws an exceptions if status() is not idle. Check all currently loaded modules for updates and apply updates if found. If no update was found, the callback is called with null. If autoApply is not set the callback will be called with all modules that will be disposed on apply().

                    method decline

                    decline: {
                    (dependencies: string[]): void;
                    (dependency: string): void;
                    (): void;
                    };
                    • Do not accept updates for the specified dependencies. If any dependencies is updated, the code update fails with code "decline".

                    • Flag the current module as not update-able. If updated the update code would fail with code "decline".

                    method dispose

                    dispose: (callback: (data: any) => void) => void;
                    • Add a one time handler, which is executed when the current module code is replaced. Here you should destroy/remove any persistent resource you have claimed/created. If you want to transfer state to the new module, add it to data object. The data will be available at module.hot.data on the new module.

                    method removeDisposeHandler

                    removeDisposeHandler: (callback: (data: any) => void) => void;
                    • Remove a dispose handler. This can useful to add a temporary dispose handler. You could i. e. replace code while in the middle of a multi-step async function.

                    method status

                    status: {
                    (): HotModuleStatus;
                    (callback: (status: HotModuleStatus) => void): void;
                    };
                    • Return one of idle, check, watch, watch-delay, prepare, ready, dispose, apply, abort or fail.

                      - idle The HMR is waiting for your call the check(). When you call it the status will change to check.

                      - check The HMR is checking for updates. If it doesn’t find updates it will change back to idle. If updates were found it will go through the steps prepare, dispose and apply. Than back to idle.

                      - watch The HMR is in watch mode and will automatically be notified about changes. After the first change it will change to watch-delay and wait for a specified time to start the update process. Any change will reset the timeout, to accumulate more changes. When the update process is started it will go through the steps prepare, dispose and apply. Than back to watch or watch-delay if changes were detected while updating.

                      - prepare The HMR is prepare stuff for the update. This may means that it’s downloading something.

                      - ready An update is available and prepared. Call apply() to continue.

                      - dispose The HMR is calling the dispose handlers of modules that will be replaced.

                      - apply The HMR is calling the accept handlers of the parents of replaced modules, than it requires the self accepted modules.

                      - abort A update cannot apply, but the system is still in a (old) consistent state.

                      - fail A update has thrown an exception in the middle of the process, and the system is (maybe) in a inconsistent state. The system should be restarted.

                    • Register a callback on status change.

                    Type Aliases

                    type HotModuleStatus

                    type HotModuleStatus =
                    | 'idle'
                    | 'check'
                    | 'watch'
                    | 'watch-delay'
                    | 'prepare'
                    | 'ready'
                    | 'dispose'
                    | 'apply'
                    | 'abort'
                    | 'fail';

                      type LoaderPlugin

                      type LoaderPlugin = {
                      fetch: (
                      address: string
                      ) => Promise<TemplateRegistryEntry> | TemplateRegistryEntry;
                      };

                        Package Files (1)

                        Dependencies (4)

                        Dev Dependencies (4)

                        Peer Dependencies (0)

                        No peer dependencies.

                        Badge

                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/aurelia-loader-webpack.

                        • Markdown
                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/aurelia-loader-webpack)
                        • HTML
                          <a href="https://www.jsdocs.io/package/aurelia-loader-webpack"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>