Socket
Socket
Sign inDemoInstall

nordnet-release-plugin

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nordnet-release-plugin - npm Package Compare versions

Comparing version 0.0.4 to 1.0.0

10

dist/index.js

@@ -72,10 +72,8 @@ 'use strict';

var content = Object.keys(chunks).filter(function (key) {
Object.keys(chunks).filter(function (key) {
return !contains(ignore, key);
}).map(function (key) {
return inject(key);
}).join('');
_fsExtra2['default'].writeFileSync(dir + '/base.js', content);
}).forEach(function (key) {
_fsExtra2['default'].writeFileSync(dir + '/' + key + '.js', inject(key));
});
}
module.exports = exports['default'];

8

package.json
{
"name": "nordnet-release-plugin",
"version": "0.0.4",
"version": "1.0.0",
"description": "Nordnet release plugin",

@@ -10,3 +10,3 @@ "main": "dist/index.js",

"coveralls": "coveralls < coverage/lcov.info",
"clean": "trash dist",
"clean": "rimraf dist",
"build": "babel src --out-dir dist",

@@ -51,8 +51,8 @@ "eslint": "eslint src test",

"jscs": "^2.0.0",
"jscs-config-nordnet": "0.0.2",
"mocha": "^2.2.5",
"npm-run-all": "^1.2.6",
"rimraf": "^2.4.2",
"sinon": "^1.15.3",
"sinon-chai": "^2.7.0",
"trash": "^2.0.0",
"rimraf": "^2.5.2",
"webpack": "^1.10.5"

@@ -59,0 +59,0 @@ },

@@ -37,3 +37,3 @@ # nordnet-release-plugin

Plugin generates `base.js` file that should be included on the page via `<script></script>` tag. Once loaded on the page `base.js` will dynamically inject `<script></script>` tags with links to all required entry points (according to webpack and nordnet-release-plugin settings).
Plugin generates one Javascript file per entry point defined in Webpack config. These js files can be included on the page via `<script></script>` tag. Once loaded on the page it will dynamically inject `<script></script>` tag with link to an actual required entry point (according to webpack and nordnet-release-plugin settings).

@@ -43,6 +43,6 @@ For example, add `<script>` tag on html page where you want to run your Javascript application

```html
<script src="init/base.js"></script>
<script src="init/index.js"></script>
```
`base.js` might have the following content (depending on your nordnet-release-plugin and webpack configuration)
`index.js` might have the following content (depending on your nordnet-release-plugin and webpack configuration)

@@ -53,5 +53,13 @@ ```js

Once `base.js` is loaded it will inject `<script>` tag on the page to load application entry point.
Once `index.js` is loaded it will inject `<script>` tag on the page to load application entry point.
**Note:** If you have multiple entry points, then nordnet-release-plugin will generate the same number of JavaScript files respectively, e.g. `init/contacts.js` and `init/blog.js` for following webpack configuration:
```js
var entry = {
contacts: ['./contacts-page.jsx'],
blog: ['./blog-page.jsx'],
};
```
## Configuration

@@ -80,8 +88,8 @@

Path that should be used when creating links to entry points in `base.js` (path where your application is deployed, e.g. '/sc/project-name/cache/v1'). Defaults to `'/'`
Path that should be used when creating links to entry points (path where your application is deployed, e.g. '/sc/project-name/cache/v1'). Defaults to `'/'`
__ignoreChunks__:
Array with chunk names that should be ignored and excluded from `base.json`. Defaults to empty array.
If your application has multiple entry points and for some reason you want to exclude some of them from being included in `base.js` then pass entry point names (as configured in webpack) to `ignoreChunks` array.
Array with chunk names that should be ignored. Defaults to empty array.
If your application has multiple entry points and for some reason you want to exclude some of them then pass entry point names (as configured in webpack) to `ignoreChunks` array.

@@ -100,3 +108,3 @@ ```js

If you are using `require.ensure()` to create split points and want to make sure that all of them don't end up in `base.js` then consider using set up describe below.
If you are using `require.ensure()` to create split points and want to make sure that all of them don't end up in `.js` for your entry point then consider using set up describe below.

@@ -124,3 +132,3 @@ Define a code split point using `require.ensure` and provide a chunk name, see [require.ensure][require-ensure] for more details

`true | false` When set to `true` then scripts will be dynamically injected on the page instead of using `document.write` in `base.json`. Defaults to `false`.
`true | false` When set to `true` then scripts will be dynamically injected on the page instead of using `document.write`. Defaults to `false`.

@@ -127,0 +135,0 @@

@@ -52,8 +52,7 @@ import fs from 'fs-extra';

const content = Object.keys(chunks)
Object.keys(chunks)
.filter(key => !contains(ignore, key))
.map(key => inject(key))
.join('');
fs.writeFileSync(`${dir}/base.js`, content);
.forEach(key => {
fs.writeFileSync(`${dir}/${key}.js`, inject(key));
});
}

@@ -10,3 +10,2 @@ import path from 'path';

const OUTPUT_DIR = path.join(__dirname, '../temp');
const outputFile = 'base.js';
const publicPath = '/sc/project/cache/dev';

@@ -44,3 +43,3 @@

describe('when single entry point', () => {
it('should generate base.js with one entry point', (done) => {
it('should generate ${entrypoint}.js for one entry point', (done) => {
const webpackConfig = {

@@ -57,3 +56,3 @@ output,

describe('when multiple entry points', () => {
it('should generate base.js with multiple entry points', (done) => {
it('should generate ${entrypoint}.js for multiple entry points', (done) => {
const webpackConfig = {

@@ -87,3 +86,3 @@ output,

describe('when async', () => {
it('should generage base.js with async injection', (done) => {
it('should generage ${entrypoint}.js with async injection', (done) => {
const webpackConfig = {

@@ -108,3 +107,3 @@ output,

describe('require.ensure without ignoreChunks', () => {
it('should generate base.js with all chunks', (done) => {
it('should generate ${entrypoint}.js with all chunks', (done) => {
const webpackConfig = {

@@ -116,6 +115,3 @@ output,

testPlugin(webpackConfig, expected({
async: [path.join(__dirname, '/fixtures/async.js')],
'1.index': [path.join(__dirname, '/fixtures/1.index.js')],
}, done));
testPlugin(webpackConfig, expected(asyncEntryPoint, done));
});

@@ -125,3 +121,3 @@ });

describe('require.ensure with ignoreChunks', () => {
it('should generate base.js without ignored chunks', (done) => {
it('should generate ${entrypoint}.js without ignored chunks', (done) => {
const webpackConfig = {

@@ -144,3 +140,3 @@ output,

describe('multiple entry points with ignored chunks', () => {
it('should generate base.js without ignored chunks', (done) => {
it('should generate ${entrypoint}.js without ignored chunks', (done) => {
const webpackConfig = {

@@ -165,3 +161,3 @@ output,

describe('hidden-source-map', () => {
it('should generate base.js without links to source maps', (done) => {
it('should generate ${entrypoint}.js without links to source maps', (done) => {
const webpackConfig = {

@@ -189,3 +185,3 @@ output: {

describe('source-map', () => {
it('should generate base.js without links to source maps', (done) => {
it('should generate ${entrypoint}.js without links to source maps', (done) => {
const webpackConfig = {

@@ -213,3 +209,3 @@ output: {

describe('inline-source-map', () => {
it('should generate base.js without links to source maps', (done) => {
it('should generate ${entrypoint}.js without links to source maps', (done) => {
const webpackConfig = {

@@ -239,11 +235,8 @@ output: {

function expected(entry, done, async) {
const results = Object.keys(entry)
.map(key => mapResult(key, async))
.join('');
const files = Object.keys(entry).map(key => ({
file: `${key}.js`,
content: mapResult(key, async),
}));
return {
done,
outputFile,
results,
};
return { done, files };
}

@@ -278,5 +271,7 @@

function assertContent(expectedResults) {
const content = fs.readFileSync(path.join(OUTPUT_DIR, expectedResults.outputFile)).toString();
expect(content).to.equal(expectedResults.results);
function assertContent({ files }) {
files.forEach(({ file, content }) => {
const actualContent = fs.readFileSync(path.join(OUTPUT_DIR, file)).toString();
expect(actualContent).to.equal(content);
});
}

@@ -283,0 +278,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc