@parcel/core
Advanced tools
Comparing version 2.0.0-canary.1620 to 2.0.0-canary.1622
@@ -18,9 +18,2 @@ "use strict"; | ||
} | ||
function _rust() { | ||
const data = require("@parcel/rust"); | ||
_rust = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _serializer = require("../serializer.js"); | ||
@@ -45,2 +38,9 @@ function _logger() { | ||
var _assetUtils = require("../assetUtils"); | ||
function _rust() { | ||
const data = require("@parcel/rust"); | ||
_rust = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _profiler() { | ||
@@ -56,9 +56,2 @@ const data = require("@parcel/profiler"); | ||
var _buildCache = require("../buildCache"); | ||
function _featureFlags() { | ||
const data = require("@parcel/feature-flags"); | ||
_featureFlags = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
@@ -132,14 +125,2 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
}) => { | ||
if ((0, _featureFlags().getFeatureFlag)('parcelV3')) { | ||
return (0, _rust().napiRunConfigRequest)({ | ||
id: configRequest.id, | ||
invalidateOnBuild: configRequest.invalidateOnBuild, | ||
invalidateOnConfigKeyChange: configRequest.invalidateOnConfigKeyChange, | ||
invalidateOnFileCreate: configRequest.invalidateOnFileCreate, | ||
invalidateOnEnvChange: Array.from(configRequest.invalidateOnEnvChange), | ||
invalidateOnOptionChange: Array.from(configRequest.invalidateOnOptionChange), | ||
invalidateOnStartup: configRequest.invalidateOnStartup, | ||
invalidateOnFileChange: Array.from(configRequest.invalidateOnFileChange) | ||
}, api, options); | ||
} | ||
for (let filePath of invalidateOnFileChange) { | ||
@@ -146,0 +127,0 @@ api.invalidateOnFileUpdate(filePath); |
{ | ||
"name": "@parcel/core", | ||
"version": "2.0.0-canary.1620+062993bab", | ||
"version": "2.0.0-canary.1622+7fb3eb824", | ||
"license": "MIT", | ||
@@ -28,17 +28,17 @@ "publishConfig": { | ||
"@mischnic/json-sourcemap": "^0.1.0", | ||
"@parcel/cache": "2.0.0-canary.1622+062993bab", | ||
"@parcel/diagnostic": "2.0.0-canary.1622+062993bab", | ||
"@parcel/events": "2.0.0-canary.1622+062993bab", | ||
"@parcel/feature-flags": "2.12.1-canary.3245+062993bab", | ||
"@parcel/fs": "2.0.0-canary.1622+062993bab", | ||
"@parcel/graph": "3.2.1-canary.3245+062993bab", | ||
"@parcel/logger": "2.0.0-canary.1622+062993bab", | ||
"@parcel/package-manager": "2.0.0-canary.1622+062993bab", | ||
"@parcel/plugin": "2.0.0-canary.1622+062993bab", | ||
"@parcel/profiler": "2.12.1-canary.3245+062993bab", | ||
"@parcel/rust": "2.12.1-canary.3245+062993bab", | ||
"@parcel/cache": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/diagnostic": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/events": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/feature-flags": "2.12.1-canary.3247+7fb3eb824", | ||
"@parcel/fs": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/graph": "3.2.1-canary.3247+7fb3eb824", | ||
"@parcel/logger": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/package-manager": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/plugin": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/profiler": "2.12.1-canary.3247+7fb3eb824", | ||
"@parcel/rust": "2.12.1-canary.3247+7fb3eb824", | ||
"@parcel/source-map": "^2.1.1", | ||
"@parcel/types": "2.0.0-canary.1622+062993bab", | ||
"@parcel/utils": "2.0.0-canary.1622+062993bab", | ||
"@parcel/workers": "2.0.0-canary.1622+062993bab", | ||
"@parcel/types": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/utils": "2.0.0-canary.1624+7fb3eb824", | ||
"@parcel/workers": "2.0.0-canary.1624+7fb3eb824", | ||
"base-x": "^3.0.8", | ||
@@ -61,3 +61,3 @@ "browserslist": "^4.6.6", | ||
}, | ||
"gitHead": "062993bab608c05a92027bc56da4f1192e8a97ed" | ||
"gitHead": "7fb3eb82493dbb01c6da245b62b35844dedb89fc" | ||
} |
@@ -20,3 +20,2 @@ // @flow | ||
import type {ProjectPath} from '../projectPath'; | ||
import {napiRunConfigRequest} from '@parcel/rust'; | ||
@@ -35,3 +34,2 @@ import {serializeRaw} from '../serializer.js'; | ||
import {createBuildCache} from '../buildCache'; | ||
import {getFeatureFlag} from '@parcel/feature-flags'; | ||
@@ -181,26 +179,2 @@ export type PluginWithLoadConfig = { | ||
run: async ({api, options}) => { | ||
if (getFeatureFlag('parcelV3')) { | ||
return napiRunConfigRequest( | ||
{ | ||
id: configRequest.id, | ||
invalidateOnBuild: configRequest.invalidateOnBuild, | ||
invalidateOnConfigKeyChange: | ||
configRequest.invalidateOnConfigKeyChange, | ||
invalidateOnFileCreate: configRequest.invalidateOnFileCreate, | ||
invalidateOnEnvChange: Array.from( | ||
configRequest.invalidateOnEnvChange, | ||
), | ||
invalidateOnOptionChange: Array.from( | ||
configRequest.invalidateOnOptionChange, | ||
), | ||
invalidateOnStartup: configRequest.invalidateOnStartup, | ||
invalidateOnFileChange: Array.from( | ||
configRequest.invalidateOnFileChange, | ||
), | ||
}, | ||
api, | ||
options, | ||
); | ||
} | ||
for (let filePath of invalidateOnFileChange) { | ||
@@ -207,0 +181,0 @@ api.invalidateOnFileUpdate(filePath); |
@@ -7,3 +7,2 @@ // @flow strict-local | ||
import sinon from 'sinon'; | ||
import {DEFAULT_FEATURE_FLAGS, setFeatureFlags} from '@parcel/feature-flags'; | ||
import {MemoryFS} from '@parcel/fs'; | ||
@@ -23,13 +22,2 @@ import {hashString} from '@parcel/rust'; | ||
async function assertThrows(block: () => Promise<void>) { | ||
let error: Error | null = null; | ||
try { | ||
await block(); | ||
} catch (e) { | ||
error = e; | ||
} | ||
assert(error != null, 'Function finished without errors'); | ||
return error; | ||
} | ||
describe('ConfigRequest tests', () => { | ||
@@ -86,247 +74,184 @@ const projectRoot = 'project_root'; | ||
['rust', 'js'].forEach(backend => { | ||
describe(`${backend} backed`, () => { | ||
beforeEach(() => { | ||
setFeatureFlags({ | ||
...DEFAULT_FEATURE_FLAGS, | ||
parcelV3: backend === 'rust', | ||
}); | ||
}); | ||
it('can execute a config request', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
}); | ||
}); | ||
it('can execute a config request', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
}); | ||
}); | ||
it('forwards "invalidateOnFileChange" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnFileChange: new Set([ | ||
toProjectPath(projectRoot, 'path1'), | ||
toProjectPath(projectRoot, 'path2'), | ||
]), | ||
}); | ||
if (backend === 'rust') { | ||
// Adding this here mostly to prove that the rust backend is actually running on | ||
// this suite | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileUpdate).called, | ||
'Invalidate was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileUpdate).calledWith('path1'), | ||
'Invalidate was called with path1', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileUpdate).calledWith('path2'), | ||
'Invalidate was called with path2', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileDelete).calledWith('path1'), | ||
'Invalidate was called with path1', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileDelete).calledWith('path2'), | ||
'Invalidate was called with path2', | ||
); | ||
}); | ||
it('errors out if the options are missing projectRoot', async () => { | ||
const mockRunApi = getMockRunApi({ | ||
inputFS: fs, | ||
}); | ||
const error = await assertThrows(async () => { | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnStartup: true, | ||
}); | ||
}); | ||
assert.equal( | ||
error?.message, | ||
'[napi] Missing required projectRoot options field', | ||
); | ||
}); | ||
it('forwards "invalidateOnFileCreate" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnFileCreate: [ | ||
{filePath: toProjectPath(projectRoot, 'filePath')}, | ||
{glob: toProjectPath(projectRoot, 'glob')}, | ||
{ | ||
fileName: 'package.json', | ||
aboveFilePath: toProjectPath(projectRoot, 'fileAbove'), | ||
}, | ||
], | ||
}); | ||
it('errors out if the options are missing inputFS', async () => { | ||
const mockRunApi = getMockRunApi({ | ||
projectRoot, | ||
}); | ||
const error = await assertThrows(async () => { | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnStartup: true, | ||
}); | ||
}); | ||
assert.equal( | ||
error?.message, | ||
'[napi] Missing required inputFS options field', | ||
); | ||
}); | ||
} | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileCreate).called, | ||
'Invalidate was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileCreate).calledWithMatch({ | ||
filePath: 'filePath', | ||
}), | ||
'Invalidate was called for path', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileCreate).calledWithMatch({ | ||
glob: 'glob', | ||
}), | ||
'Invalidate was called for glob', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileCreate).calledWithMatch({ | ||
fileName: 'package.json', | ||
aboveFilePath: 'fileAbove', | ||
}), | ||
'Invalidate was called for fileAbove', | ||
); | ||
}); | ||
it('forwards "invalidateOnFileChange" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnFileChange: new Set([ | ||
toProjectPath(projectRoot, 'path1'), | ||
toProjectPath(projectRoot, 'path2'), | ||
]), | ||
}); | ||
it('forwards "invalidateOnEnvChange" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnEnvChange: new Set(['env1', 'env2']), | ||
}); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileUpdate).called, | ||
'Invalidate was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileUpdate).calledWith('path1'), | ||
'Invalidate was called with path1', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileUpdate).calledWith('path2'), | ||
'Invalidate was called with path2', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileDelete).calledWith('path1'), | ||
'Invalidate was called with path1', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileDelete).calledWith('path2'), | ||
'Invalidate was called with path2', | ||
); | ||
}); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnEnvChange).called, | ||
'Invalidate was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnEnvChange).calledWithMatch('env1'), | ||
'Invalidate was called for env1', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnEnvChange).calledWithMatch('env2'), | ||
'Invalidate was called for env1', | ||
); | ||
}); | ||
it('forwards "invalidateOnFileCreate" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnFileCreate: [ | ||
{filePath: toProjectPath(projectRoot, 'filePath')}, | ||
{glob: toProjectPath(projectRoot, 'glob')}, | ||
{ | ||
fileName: 'package.json', | ||
aboveFilePath: toProjectPath(projectRoot, 'fileAbove'), | ||
}, | ||
], | ||
}); | ||
it('forwards "invalidateOnOptionChange" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnOptionChange: new Set(['option1', 'option2']), | ||
}); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileCreate).called, | ||
'Invalidate was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileCreate).calledWithMatch({ | ||
filePath: 'filePath', | ||
}), | ||
'Invalidate was called for path', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileCreate).calledWithMatch({ | ||
glob: 'glob', | ||
}), | ||
'Invalidate was called for glob', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnFileCreate).calledWithMatch({ | ||
fileName: 'package.json', | ||
aboveFilePath: 'fileAbove', | ||
}), | ||
'Invalidate was called for fileAbove', | ||
); | ||
}); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnOptionChange).called, | ||
'Invalidate was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnOptionChange).calledWithMatch('option1'), | ||
'Invalidate was called for option1', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnOptionChange).calledWithMatch('option2'), | ||
'Invalidate was called for option2', | ||
); | ||
}); | ||
it('forwards "invalidateOnEnvChange" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnEnvChange: new Set(['env1', 'env2']), | ||
}); | ||
it('forwards "invalidateOnStartup" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnStartup: true, | ||
}); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnEnvChange).called, | ||
'Invalidate was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnEnvChange).calledWithMatch('env1'), | ||
'Invalidate was called for env1', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnEnvChange).calledWithMatch('env2'), | ||
'Invalidate was called for env1', | ||
); | ||
}); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnStartup).called, | ||
'Invalidate was called', | ||
); | ||
}); | ||
it('forwards "invalidateOnOptionChange" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnOptionChange: new Set(['option1', 'option2']), | ||
}); | ||
it('forwards "invalidateOnBuild" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnBuild: true, | ||
}); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnOptionChange).called, | ||
'Invalidate was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnOptionChange).calledWithMatch( | ||
'option1', | ||
assert( | ||
mockCast(mockRunApi.invalidateOnBuild).called, | ||
'Invalidate was called', | ||
); | ||
}); | ||
it('forwards "invalidateOnConfigKeyChange" calls to runAPI', async () => { | ||
await fs.mkdirp('/project_root'); | ||
await fs.writeFile( | ||
'/project_root/config.json', | ||
JSON.stringify({key1: 'value1'}), | ||
); | ||
sinon.spy(fs, 'readFile'); | ||
sinon.spy(fs, 'readFileSync'); | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnConfigKeyChange: [ | ||
{ | ||
configKey: 'key1', | ||
filePath: toProjectPath( | ||
projectRoot, | ||
path.join('project_root', 'config.json'), | ||
), | ||
'Invalidate was called for option1', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnOptionChange).calledWithMatch( | ||
'option2', | ||
), | ||
'Invalidate was called for option2', | ||
); | ||
}); | ||
}, | ||
], | ||
}); | ||
it('forwards "invalidateOnStartup" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnStartup: true, | ||
}); | ||
const fsCall = mockCast(fs).readFile.getCall(0); | ||
assert.deepEqual( | ||
fsCall?.args, | ||
[path.join('project_root', 'config.json'), 'utf8'], | ||
'readFile was called', | ||
); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnStartup).called, | ||
'Invalidate was called', | ||
); | ||
}); | ||
it('forwards "invalidateOnBuild" calls to runAPI', async () => { | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnBuild: true, | ||
}); | ||
assert( | ||
mockCast(mockRunApi.invalidateOnBuild).called, | ||
'Invalidate was called', | ||
); | ||
}); | ||
it('forwards "invalidateOnConfigKeyChange" calls to runAPI', async () => { | ||
await fs.mkdirp('/project_root'); | ||
await fs.writeFile( | ||
'/project_root/config.json', | ||
JSON.stringify({key1: 'value1'}), | ||
); | ||
sinon.spy(fs, 'readFile'); | ||
sinon.spy(fs, 'readFileSync'); | ||
const mockRunApi = getMockRunApi(); | ||
await runConfigRequest(mockRunApi, { | ||
...baseRequest, | ||
invalidateOnConfigKeyChange: [ | ||
{ | ||
configKey: 'key1', | ||
filePath: toProjectPath( | ||
projectRoot, | ||
path.join('project_root', 'config.json'), | ||
), | ||
}, | ||
], | ||
}); | ||
if (backend === 'rust') { | ||
const fsCall = mockCast(fs).readFileSync.getCall(0); | ||
assert.deepEqual( | ||
fsCall?.args, | ||
[path.join('project_root', 'config.json')], | ||
'readFile was called', | ||
); | ||
} else { | ||
const fsCall = mockCast(fs).readFile.getCall(0); | ||
assert.deepEqual( | ||
fsCall?.args, | ||
[path.join('project_root', 'config.json'), 'utf8'], | ||
'readFile was called', | ||
); | ||
} | ||
const call = mockCast(mockRunApi.invalidateOnConfigKeyChange).getCall( | ||
0, | ||
); | ||
assert.deepEqual( | ||
call.args, | ||
['config.json', 'key1', hashString('"value1"')], | ||
'Invalidate was called for key1', | ||
); | ||
}); | ||
}); | ||
const call = mockCast(mockRunApi.invalidateOnConfigKeyChange).getCall(0); | ||
assert.deepEqual( | ||
call.args, | ||
['config.json', 'key1', hashString('"value1"')], | ||
'Invalidate was called for key1', | ||
); | ||
}); | ||
}); |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
1388047
39859