@atlaspack/core 2.12.1-canary.3478 → 2.12.1-canary.3480

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,55 +4,75 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PluginConfig = void 0;
7
+ var _Config = _interopRequireDefault(require("../../../public/Config"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
9
  class PluginConfig {
10
+ #projectRoot;
11
+ #inner;
8
12
  constructor({
9
13
  env,
10
14
  isSource,
11
- searchPath
15
+ searchPath,
16
+ projectRoot,
17
+ fs,
18
+ packageManager
12
19
  }) {
13
20
  this.env = env;
14
21
  this.isSource = isSource;
15
22
  this.searchPath = searchPath;
23
+ this.#inner = new _Config.default(
24
+ // $FlowFixMe
25
+ {
26
+ invalidateOnConfigKeyChange: [],
27
+ invalidateOnFileCreate: [],
28
+ invalidateOnFileChange: new Set(),
29
+ devDeps: [],
30
+ // $FlowFixMe
31
+ searchPath: searchPath.replace(projectRoot + '/', '')
32
+ },
33
+ // $FlowFixMe
34
+ {
35
+ projectRoot,
36
+ inputFS: fs,
37
+ outputFS: fs,
38
+ packageManager
39
+ });
16
40
  }
17
41
 
18
42
  // eslint-disable-next-line no-unused-vars
19
- invalidateOnFileChange() {
20
- throw new Error('PluginOptions.invalidateOnFileChange');
21
- }
43
+ invalidateOnFileChange() {}
22
44
 
23
45
  // eslint-disable-next-line no-unused-vars
24
- invalidateOnFileCreate() {
25
- throw new Error('PluginOptions.invalidateOnFileCreate');
26
- }
46
+ invalidateOnFileCreate() {}
27
47
 
28
48
  // eslint-disable-next-line no-unused-vars
29
- invalidateOnEnvChange() {
30
- throw new Error('PluginOptions.invalidateOnEnvChange');
31
- }
32
- invalidateOnStartup() {
33
- throw new Error('PluginOptions.invalidateOnStartup');
34
- }
35
- invalidateOnBuild() {
36
- throw new Error('PluginOptions.invalidateOnBuild');
37
- }
49
+ invalidateOnEnvChange() {}
50
+ invalidateOnStartup() {}
51
+ invalidateOnBuild() {}
38
52
 
39
53
  // eslint-disable-next-line no-unused-vars
40
- addDevDependency() {
41
- throw new Error('PluginOptions.addDevDependency');
42
- }
54
+ addDevDependency() {}
43
55
 
44
56
  // eslint-disable-next-line no-unused-vars
45
- setCacheKey() {
46
- throw new Error('PluginOptions.setCacheKey');
47
- }
48
- getConfig() {
49
- throw new Error('PluginOptions.getConfig');
57
+ setCacheKey() {}
58
+ getConfig(
59
+ // eslint-disable-next-line no-unused-vars
60
+ filePaths,
61
+ // eslint-disable-next-line no-unused-vars
62
+ options) {
63
+ return this.#inner.getConfig(filePaths, options);
50
64
  }
51
- getConfigFrom() {
52
- throw new Error('PluginOptions.getConfigFrom');
65
+ getConfigFrom(
66
+ // eslint-disable-next-line no-unused-vars
67
+ searchPath,
68
+ // eslint-disable-next-line no-unused-vars
69
+ filePaths,
70
+ // eslint-disable-next-line no-unused-vars
71
+ options) {
72
+ return this.#inner.getConfigFrom(searchPath, filePaths, options);
53
73
  }
54
74
  getPackage() {
55
- throw new Error('PluginOptions.getPackage');
75
+ return this.#inner.getPackage();
56
76
  }
57
77
  }
58
78
  exports.PluginConfig = PluginConfig;
@@ -96,7 +96,7 @@ class AtlaspackWorker {
96
96
  dependency: napiDependency,
97
97
  specifier,
98
98
  pipeline,
99
- options
99
+ pluginOptions
100
100
  }) => {
101
101
  const state = this.#resolvers.get(key);
102
102
  if (!state) {
@@ -104,7 +104,7 @@ class AtlaspackWorker {
104
104
  }
105
105
  let packageManager = state.packageManager;
106
106
  if (!packageManager) {
107
- packageManager = new (_packageManager().NodePackageManager)(this.#fs, options.projectRoot);
107
+ packageManager = new (_packageManager().NodePackageManager)(this.#fs, pluginOptions.projectRoot);
108
108
  state.packageManager = packageManager;
109
109
  }
110
110
  const env = new _compat.Environment(napiDependency.env);
@@ -113,7 +113,7 @@ class AtlaspackWorker {
113
113
  logger: new _compat.PluginLogger(),
114
114
  tracer: new _compat.PluginTracer(),
115
115
  options: new _compat.PluginOptions({
116
- ...options,
116
+ ...pluginOptions,
117
117
  packageManager,
118
118
  shouldAutoInstall: false,
119
119
  inputFS: this.#fs,
@@ -126,7 +126,10 @@ class AtlaspackWorker {
126
126
  config: new _compat.PluginConfig({
127
127
  env,
128
128
  isSource: true,
129
- searchPath: ''
129
+ searchPath: specifier,
130
+ projectRoot: pluginOptions.projectRoot,
131
+ fs: this.#fs,
132
+ packageManager
130
133
  }),
131
134
  ...defaultOptions
132
135
  }));
@@ -198,7 +201,10 @@ class AtlaspackWorker {
198
201
  config: new _compat.PluginConfig({
199
202
  env,
200
203
  isSource: true,
201
- searchPath: ''
204
+ searchPath: innerAsset.filePath.replace(options.projectRoot + '/', ''),
205
+ projectRoot: options.projectRoot,
206
+ fs: this.#fs,
207
+ packageManager
202
208
  }),
203
209
  ...defaultOptions
204
210
  }));
@@ -18,7 +18,15 @@ function _diagnostic() {
18
18
  };
19
19
  return data;
20
20
  }
21
+ function _rust() {
22
+ const data = require("@atlaspack/rust");
23
+ _rust = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
21
28
  var _AssetGraph = _interopRequireWildcard(require("../AssetGraph"));
29
+ var _constants = require("../constants");
22
30
  var _projectPath = require("../projectPath");
23
31
  var _RequestTracker = require("../RequestTracker");
24
32
  var _SymbolPropagation = require("../SymbolPropagation");
@@ -163,6 +171,12 @@ function getAssetGraph(serializedGraph, options) {
163
171
  filePath: (0, _projectPath.toProjectPath)(options.projectRoot, asset.filePath),
164
172
  symbols: asset.symbols != null ? new Map(asset.symbols.map(mapSymbols)) : null
165
173
  };
174
+ if (asset.map) {
175
+ let mapKey = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:map:${asset.id}`);
176
+ asset.mapKey = mapKey;
177
+ options.cache.setBlob(mapKey, asset.map);
178
+ delete asset.map;
179
+ }
166
180
  cachedAssets.set(id, asset.code);
167
181
  changedAssets.set(id, asset);
168
182
  graph.addNodeByContentKey(id, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.12.1-canary.3478+7832352eb",
3
+ "version": "2.12.1-canary.3480+cce14fe9d",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,21 +20,21 @@
20
20
  "check-ts": "tsc --noEmit index.d.ts"
21
21
  },
22
22
  "dependencies": {
23
- "@atlaspack/build-cache": "2.12.1-canary.3478+7832352eb",
24
- "@atlaspack/cache": "2.12.1-canary.3478+7832352eb",
25
- "@atlaspack/diagnostic": "2.12.1-canary.3478+7832352eb",
26
- "@atlaspack/events": "2.12.1-canary.3478+7832352eb",
27
- "@atlaspack/feature-flags": "2.12.1-canary.3478+7832352eb",
28
- "@atlaspack/fs": "2.12.1-canary.3478+7832352eb",
29
- "@atlaspack/graph": "3.2.1-canary.3478+7832352eb",
30
- "@atlaspack/logger": "2.12.1-canary.3478+7832352eb",
31
- "@atlaspack/package-manager": "2.12.1-canary.3478+7832352eb",
32
- "@atlaspack/plugin": "2.12.1-canary.3478+7832352eb",
33
- "@atlaspack/profiler": "2.12.1-canary.3478+7832352eb",
34
- "@atlaspack/rust": "2.12.1-canary.3478+7832352eb",
35
- "@atlaspack/types": "2.12.1-canary.3478+7832352eb",
36
- "@atlaspack/utils": "2.12.1-canary.3478+7832352eb",
37
- "@atlaspack/workers": "2.12.1-canary.3478+7832352eb",
23
+ "@atlaspack/build-cache": "2.12.1-canary.3480+cce14fe9d",
24
+ "@atlaspack/cache": "2.12.1-canary.3480+cce14fe9d",
25
+ "@atlaspack/diagnostic": "2.12.1-canary.3480+cce14fe9d",
26
+ "@atlaspack/events": "2.12.1-canary.3480+cce14fe9d",
27
+ "@atlaspack/feature-flags": "2.12.1-canary.3480+cce14fe9d",
28
+ "@atlaspack/fs": "2.12.1-canary.3480+cce14fe9d",
29
+ "@atlaspack/graph": "3.2.1-canary.3480+cce14fe9d",
30
+ "@atlaspack/logger": "2.12.1-canary.3480+cce14fe9d",
31
+ "@atlaspack/package-manager": "2.12.1-canary.3480+cce14fe9d",
32
+ "@atlaspack/plugin": "2.12.1-canary.3480+cce14fe9d",
33
+ "@atlaspack/profiler": "2.12.1-canary.3480+cce14fe9d",
34
+ "@atlaspack/rust": "2.12.1-canary.3480+cce14fe9d",
35
+ "@atlaspack/types": "2.12.1-canary.3480+cce14fe9d",
36
+ "@atlaspack/utils": "2.12.1-canary.3480+cce14fe9d",
37
+ "@atlaspack/workers": "2.12.1-canary.3480+cce14fe9d",
38
38
  "@mischnic/json-sourcemap": "^0.1.0",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
@@ -65,5 +65,5 @@
65
65
  "browser": {
66
66
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
67
67
  },
68
- "gitHead": "7832352eb05e5982f2221de5666d8ae0a6e9cb30"
68
+ "gitHead": "cce14fe9d03ac450dee42be4d0d4ab7d1e15bd68"
69
69
  }
@@ -8,57 +8,78 @@ import type {
8
8
  FileCreateInvalidation,
9
9
  ConfigResultWithFilePath,
10
10
  PackageJSON,
11
+ PackageManager as IPackageManager,
11
12
  } from '@atlaspack/types';
12
13
 
14
+ import type {FileSystem as IFileSystem} from '@atlaspack/fs';
15
+ import ClassicPublicConfig from '../../../public/Config';
16
+
13
17
  export type PluginConfigOptions = {|
14
18
  isSource: boolean,
15
19
  searchPath: FilePath,
20
+ projectRoot: FilePath,
16
21
  env: Environment,
22
+ fs: IFileSystem,
23
+ packageManager: IPackageManager,
17
24
  |};
18
25
 
19
26
  export class PluginConfig implements IPluginConfig {
20
27
  isSource: boolean;
21
28
  searchPath: FilePath;
29
+ #projectRoot: FilePath;
22
30
  env: Environment;
31
+ #inner: ClassicPublicConfig;
23
32
 
24
- constructor({env, isSource, searchPath}: PluginConfigOptions) {
33
+ constructor({
34
+ env,
35
+ isSource,
36
+ searchPath,
37
+ projectRoot,
38
+ fs,
39
+ packageManager,
40
+ }: PluginConfigOptions) {
25
41
  this.env = env;
26
42
  this.isSource = isSource;
27
43
  this.searchPath = searchPath;
44
+
45
+ this.#inner = new ClassicPublicConfig(
46
+ // $FlowFixMe
47
+ {
48
+ invalidateOnConfigKeyChange: [],
49
+ invalidateOnFileCreate: [],
50
+ invalidateOnFileChange: new Set(),
51
+ devDeps: [],
52
+ // $FlowFixMe
53
+ searchPath: searchPath.replace(projectRoot + '/', ''),
54
+ },
55
+ // $FlowFixMe
56
+ {
57
+ projectRoot,
58
+ inputFS: fs,
59
+ outputFS: fs,
60
+ packageManager,
61
+ },
62
+ );
28
63
  }
29
64
 
30
65
  // eslint-disable-next-line no-unused-vars
31
- invalidateOnFileChange(filePath: FilePath): void {
32
- throw new Error('PluginOptions.invalidateOnFileChange');
33
- }
66
+ invalidateOnFileChange(filePath: FilePath): void {}
34
67
 
35
68
  // eslint-disable-next-line no-unused-vars
36
- invalidateOnFileCreate(invalidations: FileCreateInvalidation): void {
37
- throw new Error('PluginOptions.invalidateOnFileCreate');
38
- }
69
+ invalidateOnFileCreate(invalidations: FileCreateInvalidation): void {}
39
70
 
40
71
  // eslint-disable-next-line no-unused-vars
41
- invalidateOnEnvChange(invalidation: string): void {
42
- throw new Error('PluginOptions.invalidateOnEnvChange');
43
- }
72
+ invalidateOnEnvChange(invalidation: string): void {}
44
73
 
45
- invalidateOnStartup(): void {
46
- throw new Error('PluginOptions.invalidateOnStartup');
47
- }
74
+ invalidateOnStartup(): void {}
48
75
 
49
- invalidateOnBuild(): void {
50
- throw new Error('PluginOptions.invalidateOnBuild');
51
- }
76
+ invalidateOnBuild(): void {}
52
77
 
53
78
  // eslint-disable-next-line no-unused-vars
54
- addDevDependency(options: DevDepOptions): void {
55
- throw new Error('PluginOptions.addDevDependency');
56
- }
79
+ addDevDependency(options: DevDepOptions): void {}
57
80
 
58
81
  // eslint-disable-next-line no-unused-vars
59
- setCacheKey(key: string): void {
60
- throw new Error('PluginOptions.setCacheKey');
61
- }
82
+ setCacheKey(key: string): void {}
62
83
 
63
84
  getConfig<T>(
64
85
  // eslint-disable-next-line no-unused-vars
@@ -70,7 +91,7 @@ export class PluginConfig implements IPluginConfig {
70
91
  exclude?: boolean,
71
92
  |},
72
93
  ): Promise<?ConfigResultWithFilePath<T>> {
73
- throw new Error('PluginOptions.getConfig');
94
+ return this.#inner.getConfig(filePaths, options);
74
95
  }
75
96
 
76
97
  getConfigFrom<T>(
@@ -85,10 +106,10 @@ export class PluginConfig implements IPluginConfig {
85
106
  exclude?: boolean,
86
107
  |},
87
108
  ): Promise<?ConfigResultWithFilePath<T>> {
88
- throw new Error('PluginOptions.getConfigFrom');
109
+ return this.#inner.getConfigFrom(searchPath, filePaths, options);
89
110
  }
90
111
 
91
112
  getPackage(): Promise<?PackageJSON> {
92
- throw new Error('PluginOptions.getPackage');
113
+ return this.#inner.getPackage();
93
114
  }
94
115
  }
@@ -76,7 +76,13 @@ export class AtlaspackWorker {
76
76
  [RunResolverResolveOptions],
77
77
  Promise<RunResolverResolveResult>,
78
78
  > = jsCallable(
79
- async ({key, dependency: napiDependency, specifier, pipeline, options}) => {
79
+ async ({
80
+ key,
81
+ dependency: napiDependency,
82
+ specifier,
83
+ pipeline,
84
+ pluginOptions,
85
+ }) => {
80
86
  const state = this.#resolvers.get(key);
81
87
  if (!state) {
82
88
  throw new Error(`Resolver not found: ${key}`);
@@ -84,7 +90,10 @@ export class AtlaspackWorker {
84
90
 
85
91
  let packageManager = state.packageManager;
86
92
  if (!packageManager) {
87
- packageManager = new NodePackageManager(this.#fs, options.projectRoot);
93
+ packageManager = new NodePackageManager(
94
+ this.#fs,
95
+ pluginOptions.projectRoot,
96
+ );
88
97
  state.packageManager = packageManager;
89
98
  }
90
99
 
@@ -95,7 +104,7 @@ export class AtlaspackWorker {
95
104
  logger: new PluginLogger(),
96
105
  tracer: new PluginTracer(),
97
106
  options: new PluginOptions({
98
- ...options,
107
+ ...pluginOptions,
99
108
  packageManager,
100
109
  shouldAutoInstall: false,
101
110
  inputFS: this.#fs,
@@ -108,7 +117,10 @@ export class AtlaspackWorker {
108
117
  config: new PluginConfig({
109
118
  env,
110
119
  isSource: true,
111
- searchPath: '',
120
+ searchPath: specifier,
121
+ projectRoot: pluginOptions.projectRoot,
122
+ fs: this.#fs,
123
+ packageManager,
112
124
  }),
113
125
  ...defaultOptions,
114
126
  });
@@ -182,7 +194,10 @@ export class AtlaspackWorker {
182
194
  config: new PluginConfig({
183
195
  env,
184
196
  isSource: true,
185
- searchPath: '',
197
+ searchPath: innerAsset.filePath.replace(options.projectRoot + '/', ''),
198
+ projectRoot: options.projectRoot,
199
+ fs: this.#fs,
200
+ packageManager,
186
201
  }),
187
202
  ...defaultOptions,
188
203
  });
@@ -287,7 +302,7 @@ type RunResolverResolveOptions = {|
287
302
  dependency: napi.Dependency,
288
303
  specifier: FilePath,
289
304
  pipeline: ?string,
290
- options: RpcPluginOptions,
305
+ pluginOptions: RpcPluginOptions,
291
306
  |};
292
307
 
293
308
  type RunResolverResolveResult = {|
@@ -3,10 +3,12 @@
3
3
  import invariant from 'assert';
4
4
 
5
5
  import ThrowableDiagnostic from '@atlaspack/diagnostic';
6
+ import {hashString} from '@atlaspack/rust';
6
7
  import type {Async} from '@atlaspack/types';
7
8
 
8
9
  import AssetGraph, {nodeFromAssetGroup} from '../AssetGraph';
9
10
  import type {AtlaspackV3} from '../atlaspack-v3';
11
+ import {ATLASPACK_VERSION} from '../constants';
10
12
  import {toProjectPath} from '../projectPath';
11
13
  import {requestTypes, type StaticRunOpts} from '../RequestTracker';
12
14
  import {propagateSymbols} from '../SymbolPropagation';
@@ -200,6 +202,14 @@ function getAssetGraph(serializedGraph, options) {
200
202
  asset.symbols != null ? new Map(asset.symbols.map(mapSymbols)) : null,
201
203
  };
202
204
 
205
+ if (asset.map) {
206
+ let mapKey = hashString(`${ATLASPACK_VERSION}:map:${asset.id}`);
207
+
208
+ asset.mapKey = mapKey;
209
+ options.cache.setBlob(mapKey, asset.map);
210
+ delete asset.map;
211
+ }
212
+
203
213
  cachedAssets.set(id, asset.code);
204
214
  changedAssets.set(id, asset);
205
215