Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-name-amd-modules

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-name-amd-modules - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

21

lib/__tests__/index.test.js

@@ -7,2 +7,6 @@ 'use strict';

var _pluginLogger = require('liferay-npm-build-tools-common/lib/plugin-logger');
var _pluginLogger2 = _interopRequireDefault(_pluginLogger);
var _index = require('../index');

@@ -16,2 +20,19 @@

var logger = void 0;
beforeEach(function () {
_pluginLogger2.default.set(__filename, logger = new _pluginLogger2.default());
});
it('logs results correctly', function () {
var source = '\n\tdefine([], function(){})\n\t';
babel.transform(source, {
filenameRelative: __filename,
plugins: [_index2.default]
});
expect(logger.messages).toMatchSnapshot();
});
it('correctly names anonymous modules', function () {

@@ -18,0 +39,0 @@ var source = '\n\tdefine([], function(){})\n\t';

15

lib/index.js

@@ -46,8 +46,12 @@ 'use strict';

var fullModuleName = '' + packageName + moduleName;
if (unshiftName) {
args.unshift(t.stringLiteral('' + packageName + moduleName));
args.unshift(t.stringLiteral(fullModuleName));
} else {
args[0].value = '' + packageName + moduleName;
args[0].value = fullModuleName;
}
this.log.info('name-amd-modules', 'Set module name to \'' + fullModuleName + '\'');
path.stop();

@@ -69,3 +73,4 @@ }

filenameRelative: state.file.opts.filenameRelative,
opts: state.opts
opts: state.opts,
log: _pluginLogger2.default.get(state)
});

@@ -82,2 +87,6 @@ }

var _pluginLogger = require('liferay-npm-build-tools-common/lib/plugin-logger');
var _pluginLogger2 = _interopRequireDefault(_pluginLogger);
var _path = require('path');

@@ -84,0 +93,0 @@

4

package.json
{
"name": "babel-plugin-name-amd-modules",
"version": "1.4.2",
"version": "1.5.0",
"description": "A Babel plugin to give name to AMD modules based on their path and package.",

@@ -15,5 +15,5 @@ "main": "lib/index.js",

"dependencies": {
"liferay-npm-build-tools-common": "1.4.2",
"liferay-npm-build-tools-common": "1.5.0",
"read-json-sync": "^1.1.1"
}
}
import * as babel from 'babel-core';
import PluginLogger from 'liferay-npm-build-tools-common/lib/plugin-logger';
import plugin from '../index';
let logger;
beforeEach(() => {
PluginLogger.set(__filename, (logger = new PluginLogger()));
});
it('logs results correctly', () => {
const source = `
define([], function(){})
`;
babel.transform(source, {
filenameRelative: __filename,
plugins: [plugin],
});
expect(logger.messages).toMatchSnapshot();
});
it('correctly names anonymous modules', () => {

@@ -5,0 +25,0 @@ const source = `

import * as pkgs from 'liferay-npm-build-tools-common/lib/packages';
import PluginLogger from 'liferay-npm-build-tools-common/lib/plugin-logger';
import path from 'path';

@@ -57,10 +58,15 @@ import readJsonSync from 'read-json-sync';

const fullModuleName = `${packageName}${moduleName}`;
if (unshiftName) {
args.unshift(
t.stringLiteral(`${packageName}${moduleName}`)
);
args.unshift(t.stringLiteral(fullModuleName));
} else {
args[0].value = `${packageName}${moduleName}`;
args[0].value = fullModuleName;
}
this.log.info(
'name-amd-modules',
`Set module name to '${fullModuleName}'`
);
path.stop();

@@ -83,2 +89,3 @@ }

opts: state.opts,
log: PluginLogger.get(state),
});

@@ -85,0 +92,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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