All Projects → CanopyTax → webpack-system-register

CanopyTax / webpack-system-register

Licence: Apache-2.0 license
A webpack plugin that wraps your bundle in a System.register

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to webpack-system-register

Frontend Developer Roadmap
📘 Front-end developer roadmap in 2021. This repository aims to collect the most important concepts of front-end.
Stars: ✭ 233 (+565.71%)
Mutual labels:  front-end
react-native-redux-boilerplate
React Native Redux Boiler Plate
Stars: ✭ 38 (+8.57%)
Mutual labels:  front-end
front-end-interview
Front-end interview questions
Stars: ✭ 28 (-20%)
Mutual labels:  front-end
Rebble Store
Pebble app store replacement.
Stars: ✭ 240 (+585.71%)
Mutual labels:  front-end
Bower
A package manager for the web
Stars: ✭ 15,095 (+43028.57%)
Mutual labels:  front-end
resume-boilerplate
📄 简历模板
Stars: ✭ 84 (+140%)
Mutual labels:  front-end
Fetiku
front interview 前端 面试题: 持续更新中... 基础,进阶,react,vue,node,小程序,前端算法,安全,常考面试题, 如果能帮到你,就给个 star😊
Stars: ✭ 221 (+531.43%)
Mutual labels:  front-end
flot
no database CMS, written in PHP, supports themes, soon plugins, and flexible taxonomies (data types) . Hybrid static/dynamic CMS that's cached by default. Runs on anything with PHP. Still in development, but fairly stable.
Stars: ✭ 44 (+25.71%)
Mutual labels:  front-end
Front End Developer Interview Questions
A list of helpful front-end related questions you can use to interview potential candidates, test yourself or completely ignore.
Stars: ✭ 51,617 (+147377.14%)
Mutual labels:  front-end
weekly
「前端见闻」周刊 - 收集前端领域的优质文章与新鲜工具(2022 年 09 月 04日最新发布)
Stars: ✭ 46 (+31.43%)
Mutual labels:  front-end
Weapp Workflow
基于Gulp 的微信小程序前端开发工作流 💯
Stars: ✭ 241 (+588.57%)
Mutual labels:  front-end
Web
千古前端图文教程,超详细的前端入门到进阶学习笔记。从零开始学前端,做一名精致优雅的前端工程师。公众号「千古壹号」作者。
Stars: ✭ 18,274 (+52111.43%)
Mutual labels:  front-end
bouffe-front
Bouffe Front SFEIR
Stars: ✭ 14 (-60%)
Mutual labels:  front-end
Javascript Articles Monthly
JavaScript 文章精选月刊
Stars: ✭ 238 (+580%)
Mutual labels:  front-end
Health-Discernment-System
A menu based multiple chronic disease detection system which will detect if a person is suffering from a severe disease by taking an essential input image.
Stars: ✭ 25 (-28.57%)
Mutual labels:  front-end
Notes And Blog
阅读笔记及高质量博客整理
Stars: ✭ 229 (+554.29%)
Mutual labels:  front-end
BatchEncoder
BatchEncoder is an audio files conversion software.
Stars: ✭ 145 (+314.29%)
Mutual labels:  front-end
Test-Bank
Interview preparation and practice problems
Stars: ✭ 43 (+22.86%)
Mutual labels:  front-end
composer-asset-compiler
Composer plugin that installs dependencies and compiles assets based on configuration.
Stars: ✭ 19 (-45.71%)
Mutual labels:  front-end
bookmarks
在线书签管理系统
Stars: ✭ 19 (-45.71%)
Mutual labels:  front-end

webpack-system-register

A webpack plugin that wraps your bundle in a System.register call. This makes webpack bundles totally consumable by SystemJS.

Alternatives

Note that you can achieve much of the same behavior by changing your webpack config to output an AMD module, and then using externals to declare the dependencies that you want to get from SystemJS. This method is probably preferable over the webpack-system-register plugin, in most cases. One of the reasons why you may still want to use this plugin, though, is if you are having trouble configuring webpack's public path, since webpack-system-register gives you the ability to use a dynamic public path at runtime in the browser (see configuration options below).

Motivation

  • System.import webpack apps.
  • Inject SystemJS modules into webpack bundles.
  • Export variables from webpack apps into SystemJS apps.

Usage

First, install the webpack-system-register plugin.

npm install --save-dev webpack-system-register

Then add it to your webpack plugins.

// webpack.config.js
const WebpackSystemRegister = require('webpack-system-register');

module.exports = {
  ...
	plugins: [
		new WebpackSystemRegister({
			systemjsDeps: [
				/^react/, // any import that starts with react
				'react-dom', // only the `react-dom` import
				/^lodash/, // any import that starts with lodash
			],
			registerName: 'test-module', // optional name that SystemJS will know this bundle as.
		}),
	],
}

Configuration Options

All configuration options are passed as properties of the object given to the WebpackSystemRegister constructor. All properties are optional and if no configuration is provided, webpack-system-register will simply wrap you webpack bundle in a System.register call (nothing more).

  • systemjsDeps (optional): an array of dependency names that should not be bundled into the webpack bundle, but instead be provided by SystemJS. These dependency names should either be literal strings or Regular Expressions.
  • registerName (optional): a string that SystemJS will use as the name of the module. Generally speaking, this is the name by which you want other code to be able to SystemJS.import() your webpack bundle.
  • publicPath: (optional) an object with configuration options for setting webpack's output.publicPath variable dynamically
    • useSystemJSLocateDir: (optional) A subproperty of the publicPath object. If it is set to true, this will cause webpack's output.publicPath to be set dynamically at runtime, based on the URL address from which the webpack bundle was loaded by SystemJS. For example, if the webpack bundle is SystemJS.imported from url http://localhost:8080/webpack.bundle.js, the publicPath for webpack will be http://localhost:8080. Since this would completely overwrite the normal output.publicPath option that is passed directly to webpack, webpack-system-register will throw an error if both output.publicPath and publicPath are set. Additionally, at least for now, the registerName must also be provided in order to use publicPath.useSystemJSLocateDir. See example below
// Example webpack.config.js showcasing usage of `useSystemJSLocateDir`
var WebpackSystemRegister = require('webpack-system-register');

module.exports = {
  output: {
    filename: "my-bundle.js",
    publicPath: null, // This MUST not be set when using `useSystemJSLocateDir`
  },
  plugins: [
    new WebpackSystemRegister({
      registerName: 'my-bundle', // required when using `useSystemJSLocateDir`
      publicPath: {
        useSystemJSLocateDir: true, // if this is set to true, publicPath must be omitted and registerName must be provided
      }
    }
  ]
}

Exporting variables from webpack into SystemJS.

To do this, simply export the variables from your webpack entry file. They will automatically be exposed to anybody who System.imports your webpack bundle. Note that (at least right now) if you mutate an exported value that that mutation will not be re-exported like it's supposed to according to the ES6 spec. The reason for this is basically just that it's really hard for me to detect mutation so I decided not to try.

Examples

To run the examples locally, choose the webpack-app-x.x app that you want to use and rename it to webpack-app, run npm install && npm run build from inside of the basic-example directory. Then run npm start and open up your web browser to localhost:8080.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].