Gathering detailed insights and metrics for systemjs-webpack-interop
Gathering detailed insights and metrics for systemjs-webpack-interop
Gathering detailed insights and metrics for systemjs-webpack-interop
Gathering detailed insights and metrics for systemjs-webpack-interop
@babel/plugin-transform-modules-systemjs
This plugin transforms ES2015 modules to SystemJS
@firebase/auth-interop-types
@firebase/auth interop Types
@firebase/app-check-interop-types
@firebase/app-check-interop-types Types
@firebase/messaging-interop-types
@firebase/messaging-interop-types Types
An npm package for webpack bundles that are used by systemjs
npm install systemjs-webpack-interop
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
94 Stars
50 Commits
18 Forks
2 Watching
12 Branches
7 Contributors
Updated on 08 Oct 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5.6%
31,978
Compared to previous day
Last week
2.4%
161,365
Compared to previous week
Last month
18.6%
674,207
Compared to previous month
Last year
21.5%
6,133,715
Compared to previous year
1
6
An npm package for webpack bundles that are used as systemjs modules.
systemjs-webpack-interop is an npm package that exports functions that help you create a webpack bundle that is consumable by SystemJS as an in-browser module.
Specifically, the library does two things:
Webpack has several features that are geared towards better interop with SystemJS. Here are relevant links:
libraryTarget: 'system'
on that page)SystemJS
on that page)Note that systemjs-webpack-interop requires systemjs@>=6.
1npm install --save systemjs-webpack-interop 2 3# Or 4yarn add systemjs-webpack-interop
systemjs-webpack-interop will dynamically set the webpack public path based on the URL that a SystemJS module was downloaded from.
You can set the public path by adding the SystemJSPublicPathWebpackPlugin.
1// webpack.config.js 2const SystemJSPublicPathWebpackPlugin = require("systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin"); 3 4module.exports = { 5 plugins: [ 6 new SystemJSPublicPathWebpackPlugin({ 7 // optional: defaults to 1 8 // If you need the webpack public path to "chop off" some of the directories in the current module's url, you can specify a "root directory level". Note that the root directory level is read from right-to-left, with `1` indicating "current directory" and `2` indicating "up one directory": 9 rootDirectoryLevel: 1, 10 11 // ONLY NEEDED FOR WEBPACK 1-4. Not necessary for webpack@5 12 systemjsModuleName: "@org-name/project-name" 13 }) 14 ] 15};
You can also set the public path with code inside of your webpack project.
If you're using at least webpack 5.0.0-beta.15, simply add the following to the very top of your webpack entry file:
1/* For a module at http://localhost:8080/dist/js/main.js, 2 * this will set the webpack public path to be 3 * http://localhost:8080/dist/js/ 4 */ 5import "systemjs-webpack-interop/auto-public-path";
If you need the webpack public path to "chop off" some of the directories in the current module's url, you can specify a "root directory level". Note that the root directory level is read from right-to-left, with 1
indicating "current directory" and 2
indicating "up one directory":
1/* For a module at http://localhost:8080/dist/js/main.js, 2 * this will set the webpack public path to be 3 * http://localhost:8080/js/ 4 */ 5import "systemjs-webpack-interop/auto-public-path/2";
1/* For a module at http://localhost:8080/dist/js/main.js, 2 * this will set the webpack public path to be 3 * http://localhost:8080/ 4 */ 5import "systemjs-webpack-interop/auto-public-path/3";
To set the webpack public path in older versions of webpack, add the following to the very top of your webpack entry file:
1import "systemjs-webpack-interop/resource-query-public-path?systemjsModuleName=@org-name/project-name";
To set the root directory level:
1import "systemjs-webpack-interop/resource-query-public-path?systemjsModuleName=@org-name/project-name&rootDirectoryLevel=2";
To set the webpack public path in older versions of webpack, you'll need to do two things:
set-public-path.js
1/* In your webpack entry file, add the following import as the very very first import. It is important that it is first. 2 * Here's a link to learn about entry files: https://webpack.js.org/configuration/entry-context/#entry 3 */ 4import "./set-public-path.js";
1/* set-public-path.js */ 2import { setPublicPath } from "systemjs-webpack-interop"; 3 4/* Make sure your import map has the name of your module in it. Example: 5{ 6 "imports": { 7 "@org-name/my-module": "https://example.com/dist/js/main.js" 8 } 9} 10 */ 11 12// __webpack_public_path__ will be set to https://example.com/dist/js/ 13setPublicPath("foo");
If you need the webpack public path to "chop off" some of the directories in the current module's url, you can specify a "root directory level". Note that the root directory level is read from right-to-left, with 1
indicating "current directory" and 2
indicating "up one directory":
1/* For a module at http://localhost:8080/dist/js/main.js, 2 * this will set the webpack public path to be 3 * http://localhost:8080/dist/ 4 */ 5setPublicPath("foo", 2);
setPublicPath(systemjsModuleName, rootDirectoryLevel = 1)
rootDirectoryLevel
indicates which /
character in the full url string to use as the directory,
scanning the url from right-to-left.undefined
systemjs-webpack-interop exports NodeJS functions for helping you set up and verify a webpack config so that it works well with SystemJS.
Note that these functions only work if you're using webpack@>=4.30.0. Before that version of webpack, output.libraryTarget
of "system"
did not exist.
1// webpack.config.js 2const systemjsInterop = require("systemjs-webpack-interop/webpack-config"); 3 4// Pass in your webpack config, and systemjs-webpack-interop will make it 5// work better with SystemJS 6module.exports = systemjsInterop.modifyWebpackConfig({ 7 output: { 8 filename: "bundle.js" 9 }, 10 module: { 11 rules: [] 12 }, 13 devtool: "sourcemap" 14});
modifyWebpackConfig(config)
config
(optional): A webpack config object. If not provided, a default one will be created for you.A new, modified webpack config object.
1// webpack.config.js 2const systemjsInterop = require("systemjs-webpack-interop/webpack-config"); 3 4// Pass in your webpack config, and systemjs-webpack-interop will make it 5// work better with SystemJS 6module.exports = { 7 output: { 8 libraryTarget: "system" 9 }, 10 module: { 11 rules: [{ parser: { system: false } }] 12 } 13}; 14 15// Throws errors if your webpack config won't interop well with SystemJS 16systemjsInterop.checkWebpackConfig(module.exports);
checkWebpackConfig(config)
config
(required): A webpack config object to be verified. If the config object isn't following best practices for interop with systemjs, and error will be thrown.undefined
if the webpack config is valid, and an Error will be thrown otherwise.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/28 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
26 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More