Socket
Socket
Sign inDemoInstall

craco-alias

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

craco-alias - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

jest.config.json

9

mocks/jsconfig.json

@@ -9,3 +9,10 @@ {

"$dir3/*": ["src/dir3/*", "src/dir3"],
"my-package": ["./node_modules/some-package", "./node_modules/some-package/*"],
"my-package": [
"./node_modules/some-package",
"./node_modules/some-package/*"
],
"external-package": [
"/absolute_path/external-package",
"/absolute_path/external-package/*"
],
"@material-ui": ["node_modules/@material-ui/ie-10/ie-10.js"]

@@ -12,0 +19,0 @@ }

@@ -9,3 +9,10 @@ {

"$dir3/*": ["src/dir3/*", "src/dir3"],
"my-package": ["./node_modules/some-package/*", "./node_modules/some-package"],
"my-package": [
"./node_modules/some-package",
"./node_modules/some-package/*"
],
"external-package": [
"/absolute_path/external-package",
"/absolute_path/external-package/*"
],
"@material-ui": ["node_modules/@material-ui/ie-10/ie-10.js"]

@@ -12,0 +19,0 @@ }

5

package.json
{
"name": "craco-alias",
"version": "3.0.0",
"version": "3.0.1",
"description": "A craco plugin for automatic aliases generation",
"main": "plugin/index.js",
"scripts": {
"test": "jest \".*\\.test\\.js\"",
"test": "jest \".*\\.test\\.js\" --config jest.config.json",
"prepare": "husky install"

@@ -39,2 +39,3 @@ },

"jest": "^24.9.0",
"jest-serializer-path": "^0.1.15",
"lint-staged": "^11.0.0",

@@ -41,0 +42,0 @@ "prettier": "2.2.1"

@@ -31,3 +31,3 @@ const fs = require('fs')

const absoluteBaseUrl = path.join(appPath, baseUrl)
const absoluteBaseUrl = path.resolve(appPath, baseUrl)

@@ -34,0 +34,0 @@ if (options.source === 'jsconfig')

@@ -6,4 +6,4 @@ const path = require('path')

const appPath = path.resolve(__dirname, '../..')
const appJsConfig = path.join(appPath, 'mocks/jsconfig.json')
const tsConfigPath = path.join(appPath, 'mocks/tsconfig.paths.json')
const appJsConfig = path.resolve(appPath, 'mocks/jsconfig.json')
const tsConfigPath = path.resolve(appPath, 'mocks/tsconfig.paths.json')

@@ -28,2 +28,3 @@ const context = {

'my-package': './node_modules/some-package',
'external-package': '/absolute_path/external-package',
'@material-ui': 'node_modules/@material-ui/ie-10/ie-10.js',

@@ -49,26 +50,15 @@ },

const result = {
'@file': path.join(appPath, './src/file.js'),
'@file2': path.join(appPath, './src/file2.js'),
'@dir': path.join(appPath, './src/dir'),
'@dir2': path.join(appPath, './src/dir2'),
'$dir3': path.join(appPath, './src/dir3'),
'my-package': path.join(appPath, './node_modules/some-package'),
'@material-ui': path.join(
appPath,
'./node_modules/@material-ui/ie-10/ie-10.js'
),
}
const snapshotName = 'extract-aliases/snap-1'
test('should correctly extract aliases from options', () => {
expect(extractAliases(inputs.fromOptions)).toEqual(result)
expect(extractAliases(inputs.fromOptions)).toMatchSnapshot(snapshotName)
})
test('should correctly extract aliases from jsconfig', () => {
expect(extractAliases(inputs.fromJsConfig)).toEqual(result)
expect(extractAliases(inputs.fromJsConfig)).toMatchSnapshot(snapshotName)
})
test('should correctly extract aliases from tsconfig', () => {
expect(extractAliases(inputs.fromTsConfig)).toEqual(result)
expect(extractAliases(inputs.fromTsConfig)).toMatchSnapshot(snapshotName)
})
})

@@ -11,3 +11,3 @@ const path = require('path')

// make alias path absolute
result[aliasName] = path.join(absoluteBaseUrl, cleanAlias)
result[aliasName] = path.resolve(absoluteBaseUrl, cleanAlias)
}

@@ -14,0 +14,0 @@

@@ -12,3 +12,3 @@ /* eslint-disable sonarjs/no-duplicate-string */

normalizeAliases({
absoluteBaseUrl: path.join(appPath, '.'),
absoluteBaseUrl: path.resolve(appPath, '.'),
aliases: {

@@ -21,21 +21,11 @@ '@file': './src/file.js',

'my-package': './node_modules/some-package',
'external-package': '/absolute_path/external-package',
'@material-ui': 'node_modules/@material-ui/ie-10/ie-10.js',
},
})
).toEqual({
'@file': path.join(appPath, './src/file.js'),
'@file2': path.join(appPath, './src/file2.js'),
'@dir': path.join(appPath, './src/dir'),
'@dir2': path.join(appPath, './src/dir2'),
'$dir3': path.join(appPath, './src/dir3'),
'my-package': path.join(appPath, './node_modules/some-package'),
'@material-ui': path.join(
appPath,
'./node_modules/@material-ui/ie-10/ie-10.js'
),
})
).toMatchSnapshot()
expect(
normalizeAliases({
absoluteBaseUrl: path.join(appPath, './src'),
absoluteBaseUrl: path.resolve(appPath, './src'),
aliases: {

@@ -49,10 +39,4 @@ '@file': './file.js',

})
).toEqual({
'@file': path.join(appPath, './src/file.js'),
'@file2': path.join(appPath, './src/file2.js'),
'@dir': path.join(appPath, './src/dir'),
'@dir2': path.join(appPath, './src/dir2'),
'$dir3': path.join(appPath, './src/dir3'),
})
).toMatchSnapshot()
})
})

@@ -17,7 +17,3 @@ const generateModuleNameMapper = require('./generate-module-name-mapper')

expect(moduleNameMapper).toEqual({
'^@file$': paths.file,
'^@dir$': paths.dir,
'^@dir/(.*)$': `${paths.dir}/$1`,
})
expect(moduleNameMapper).toMatchSnapshot()
})

@@ -33,8 +29,4 @@

expect(moduleNameMapper).toEqual({
'^\\$file$': paths.file,
'^\\$dir$': paths.dir,
'^\\$dir/(.*)$': `${paths.dir}/$1`,
})
expect(moduleNameMapper).toMatchSnapshot()
})
})

@@ -5,19 +5,4 @@ const normalize = require('./normalize-plugin-options')

test('should return default config', () => {
expect(normalize(undefined)).toEqual({
source: 'options',
baseUrl: './',
aliases: null,
debug: false,
filter: expect.any(Function),
unsafeAllowModulesOutsideOfSrc: false,
})
expect(normalize({})).toEqual({
source: 'options',
baseUrl: './',
aliases: null,
debug: false,
filter: expect.any(Function),
unsafeAllowModulesOutsideOfSrc: false,
})
expect(normalize(undefined)).toMatchSnapshot()
expect(normalize({})).toMatchSnapshot()
})

@@ -32,9 +17,3 @@

})
).toEqual({
source: 'jsconfig',
baseUrl: './',
debug: false,
filter: expect.any(Function),
unsafeAllowModulesOutsideOfSrc: false,
})
).toMatchSnapshot()
})

@@ -49,10 +28,3 @@

})
).toEqual({
source: 'tsconfig',
baseUrl: './',
tsConfigPath: 'tsconfig.paths.json',
debug: false,
filter: expect.any(Function),
unsafeAllowModulesOutsideOfSrc: false,
})
).toMatchSnapshot()
})

@@ -71,13 +43,4 @@

})
).toEqual({
source: 'options',
baseUrl: './src',
aliases: {
'@file': './file.js',
},
debug: false,
filter: expect.any(Function),
unsafeAllowModulesOutsideOfSrc: true,
})
).toMatchSnapshot()
})
})
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