@atlaspack/core 2.12.1-dev.3443 → 2.12.1-dev.3460

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.
Files changed (94) hide show
  1. package/lib/AssetGraph.js +5 -1
  2. package/lib/Atlaspack.js +2 -2
  3. package/lib/Dependency.js +1 -1
  4. package/lib/PackagerRunner.js +45 -3
  5. package/lib/SymbolPropagation.js +25 -36
  6. package/lib/assetUtils.js +1 -1
  7. package/lib/atlaspack-v3/fs.js +31 -29
  8. package/lib/atlaspack-v3/index.js +2 -2
  9. package/lib/atlaspack-v3/jsCallable.js +9 -4
  10. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +192 -0
  11. package/lib/atlaspack-v3/worker/compat/bitflags.js +84 -0
  12. package/lib/atlaspack-v3/worker/compat/dependency.js +44 -0
  13. package/lib/atlaspack-v3/worker/compat/environment.js +68 -0
  14. package/lib/atlaspack-v3/worker/compat/index.js +104 -0
  15. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +144 -0
  16. package/lib/atlaspack-v3/worker/compat/plugin-config.js +58 -0
  17. package/lib/atlaspack-v3/worker/compat/plugin-logger.js +29 -0
  18. package/lib/atlaspack-v3/worker/compat/plugin-options.js +113 -0
  19. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +12 -0
  20. package/lib/atlaspack-v3/worker/compat/target.js +17 -0
  21. package/lib/atlaspack-v3/worker/worker.js +162 -83
  22. package/lib/projectPath.js +12 -4
  23. package/lib/requests/ConfigRequest.js +1 -1
  24. package/lib/requests/WriteBundleRequest.js +15 -15
  25. package/package.json +23 -16
  26. package/src/AssetGraph.js +15 -13
  27. package/src/Atlaspack.js +5 -6
  28. package/src/AtlaspackConfig.js +11 -9
  29. package/src/AtlaspackConfig.schema.js +1 -1
  30. package/src/BundleGraph.js +83 -79
  31. package/src/CommittedAsset.js +1 -1
  32. package/src/Dependency.js +1 -1
  33. package/src/PackagerRunner.js +56 -8
  34. package/src/ReporterRunner.js +4 -4
  35. package/src/RequestTracker.js +18 -18
  36. package/src/SymbolPropagation.js +40 -52
  37. package/src/Transformation.js +12 -12
  38. package/src/UncommittedAsset.js +2 -2
  39. package/src/Validation.js +5 -5
  40. package/src/applyRuntimes.js +2 -2
  41. package/src/assetUtils.js +1 -1
  42. package/src/atlaspack-v3/AtlaspackV3.js +1 -1
  43. package/src/atlaspack-v3/fs.js +39 -25
  44. package/src/atlaspack-v3/index.js +1 -1
  45. package/src/atlaspack-v3/jsCallable.js +11 -10
  46. package/src/atlaspack-v3/worker/compat/asset-symbols.js +225 -0
  47. package/src/atlaspack-v3/worker/compat/bitflags.js +100 -0
  48. package/src/atlaspack-v3/worker/compat/dependency.js +83 -0
  49. package/src/atlaspack-v3/worker/compat/environment.js +92 -0
  50. package/src/atlaspack-v3/worker/compat/index.js +10 -0
  51. package/src/atlaspack-v3/worker/compat/mutable-asset.js +184 -0
  52. package/src/atlaspack-v3/worker/compat/plugin-config.js +94 -0
  53. package/src/atlaspack-v3/worker/compat/plugin-logger.js +47 -0
  54. package/src/atlaspack-v3/worker/compat/plugin-options.js +137 -0
  55. package/src/atlaspack-v3/worker/compat/plugin-tracer.js +11 -0
  56. package/src/atlaspack-v3/worker/compat/target.js +27 -0
  57. package/src/atlaspack-v3/worker/worker.js +218 -113
  58. package/src/dumpGraphToGraphViz.js +1 -1
  59. package/src/loadDotEnv.js +1 -1
  60. package/src/projectPath.js +12 -4
  61. package/src/public/Asset.js +1 -1
  62. package/src/public/Bundle.js +3 -3
  63. package/src/public/BundleGraph.js +20 -20
  64. package/src/public/Config.js +1 -1
  65. package/src/public/MutableBundleGraph.js +8 -8
  66. package/src/requests/AssetGraphRequest.js +10 -10
  67. package/src/requests/AssetGraphRequestRust.js +3 -3
  68. package/src/requests/AssetRequest.js +3 -3
  69. package/src/requests/AtlaspackConfigRequest.js +5 -3
  70. package/src/requests/BundleGraphRequest.js +6 -6
  71. package/src/requests/ConfigRequest.js +5 -5
  72. package/src/requests/DevDepRequest.js +7 -7
  73. package/src/requests/EntryRequest.js +2 -2
  74. package/src/requests/TargetRequest.js +9 -8
  75. package/src/requests/ValidationRequest.js +2 -2
  76. package/src/requests/WriteBundleRequest.js +26 -20
  77. package/src/requests/WriteBundlesRequest.js +6 -6
  78. package/src/requests/asset-graph-diff.js +4 -4
  79. package/src/resolveOptions.js +3 -3
  80. package/src/serializer.js +2 -2
  81. package/src/serializerCore.browser.js +3 -2
  82. package/src/serializerCore.js +2 -2
  83. package/src/utils.js +2 -2
  84. package/test/AtlaspackConfigRequest.test.js +1 -1
  85. package/test/BundleGraph.test.js +3 -3
  86. package/test/Dependency.test.js +28 -0
  87. package/test/PublicMutableBundleGraph.test.js +2 -2
  88. package/test/RequestTracker.test.js +7 -6
  89. package/test/SymbolPropagation.test.js +9 -9
  90. package/test/requests/ConfigRequest.test.js +3 -6
  91. package/test/utils.test.js +1 -1
  92. package/lib/atlaspack-v3/worker/compat.js +0 -57
  93. package/src/atlaspack-v3/worker/compat.js +0 -82
  94. package/test/requests/WriteBundleRequest.test.js +0 -132
@@ -0,0 +1,184 @@
1
+ // @flow
2
+
3
+ import type SourceMap from '@parcel/source-map';
4
+ import * as napi from '@atlaspack/rust';
5
+ import {Readable} from 'stream';
6
+ import type {
7
+ MutableAsset as IMutableAsset,
8
+ Stats,
9
+ FileSystem,
10
+ FilePath,
11
+ Environment,
12
+ Meta,
13
+ BundleBehavior,
14
+ ASTGenerator,
15
+ AST,
16
+ Dependency,
17
+ DependencyOptions,
18
+ FileCreateInvalidation,
19
+ EnvironmentOptions,
20
+ } from '@atlaspack/types';
21
+ import {bundleBehaviorMap} from './bitflags';
22
+ import {MutableAssetSymbols} from './asset-symbols';
23
+
24
+ export type InnerAsset = napi.Asset;
25
+
26
+ export class MutableAsset implements IMutableAsset {
27
+ fs: FileSystem;
28
+ env: Environment;
29
+ symbols: MutableAssetSymbols;
30
+ stats: Stats;
31
+ id: string;
32
+ filePath: FilePath;
33
+ type: string;
34
+ query: URLSearchParams;
35
+ isSource: boolean;
36
+ meta: Meta;
37
+ bundleBehavior: ?BundleBehavior;
38
+ isBundleSplittable: boolean;
39
+ sideEffects: boolean;
40
+ uniqueKey: ?string;
41
+ pipeline: ?string;
42
+
43
+ #inner: InnerAsset;
44
+ #ast: ?AST;
45
+ #contents: Buffer;
46
+
47
+ get astGenerator(): ?ASTGenerator {
48
+ throw new Error('get MutableAsset.astGenerator');
49
+ }
50
+
51
+ set astGenerator(value: ?ASTGenerator) {
52
+ throw new Error('set MutableAsset.astGenerator');
53
+ }
54
+
55
+ constructor(asset: InnerAsset, fs: FileSystem, env: Environment) {
56
+ this.#inner = asset;
57
+ this.stats = asset.stats;
58
+ this.id = asset.id;
59
+ this.filePath = asset.filePath;
60
+ this.type;
61
+ this.symbols = new MutableAssetSymbols(asset.symbols);
62
+ this.stats = asset.stats;
63
+ this.id = asset.id;
64
+ this.filePath = asset.filePath;
65
+ this.type = asset.type;
66
+ this.query = new URLSearchParams(asset.query);
67
+ this.isSource = asset.isSource;
68
+ this.meta = asset.meta;
69
+ this.bundleBehavior = bundleBehaviorMap.fromNullable(asset.bundleBehavior);
70
+ this.isBundleSplittable = asset.isBundleSplittable;
71
+ this.sideEffects = asset.sideEffects;
72
+ this.uniqueKey = asset.uniqueKey;
73
+ this.pipeline = asset.pipeline;
74
+ this.#contents = Buffer.from(asset.code);
75
+ this.fs = fs;
76
+ this.env = env;
77
+ }
78
+
79
+ // eslint-disable-next-line require-await
80
+ async getAST(): Promise<?AST> {
81
+ return this.#ast;
82
+ }
83
+
84
+ setAST(ast: AST): void {
85
+ this.#ast = ast;
86
+ }
87
+
88
+ isASTDirty(): boolean {
89
+ throw new Error('MutableAsset.isASTDirty()');
90
+ }
91
+
92
+ // eslint-disable-next-line require-await
93
+ async getCode(): Promise<string> {
94
+ return this.#contents.toString();
95
+ }
96
+
97
+ setCode(code: string): void {
98
+ this.#contents = Buffer.from(code);
99
+ }
100
+
101
+ // eslint-disable-next-line require-await
102
+ async getBuffer(): Promise<Buffer> {
103
+ return this.#contents;
104
+ }
105
+
106
+ setBuffer(buf: Buffer): void {
107
+ this.#contents = buf;
108
+ }
109
+
110
+ getStream(): Readable {
111
+ return Readable.from(this.#contents);
112
+ }
113
+
114
+ setStream(stream: Readable): void {
115
+ const data = [];
116
+
117
+ stream.on('data', (chunk) => {
118
+ data.push(chunk);
119
+ });
120
+
121
+ stream.on('end', () => {
122
+ this.#contents = Buffer.concat(data);
123
+ });
124
+
125
+ stream.on('error', () => {
126
+ throw new Error('MutableAsset.setStream()');
127
+ });
128
+ }
129
+
130
+ getMap(): Promise<?SourceMap> {
131
+ throw new Error('MutableAsset.getMap');
132
+ }
133
+
134
+ // eslint-disable-next-line no-unused-vars
135
+ setMap(sourceMap: ?SourceMap): void {
136
+ throw new Error('MutableAsset.setMap()');
137
+ }
138
+
139
+ getMapBuffer(): Promise<?Buffer> {
140
+ throw new Error('MutableAsset.getMapBuffer');
141
+ }
142
+
143
+ getDependencies(): $ReadOnlyArray<Dependency> {
144
+ throw new Error('MutableAsset.getDependencies');
145
+ }
146
+
147
+ // eslint-disable-next-line no-unused-vars
148
+ addDependency(options: DependencyOptions): string {
149
+ throw new Error('MutableAsset.addDependency()');
150
+ }
151
+
152
+ // eslint-disable-next-line no-unused-vars
153
+ addURLDependency(url: string, opts: $Shape<DependencyOptions>): string {
154
+ throw new Error('MutableAsset.addURLDependency()');
155
+ }
156
+
157
+ // eslint-disable-next-line no-unused-vars
158
+ setEnvironment(opts: EnvironmentOptions): void {
159
+ throw new Error('MutableAsset.setEnvironment()');
160
+ }
161
+
162
+ // eslint-disable-next-line no-unused-vars
163
+ invalidateOnFileChange(invalidation: FilePath): void {
164
+ throw new Error('MutableAsset.invalidateOnFileChange()');
165
+ }
166
+
167
+ // eslint-disable-next-line no-unused-vars
168
+ invalidateOnFileCreate(invalidation: FileCreateInvalidation): void {
169
+ throw new Error('MutableAsset.invalidateOnFileCreate()');
170
+ }
171
+
172
+ // eslint-disable-next-line no-unused-vars
173
+ invalidateOnEnvChange(invalidation: string): void {
174
+ throw new Error('MutableAsset.invalidateOnEnvChange()');
175
+ }
176
+
177
+ invalidateOnStartup(): void {
178
+ throw new Error('MutableAsset.invalidateOnStartup()');
179
+ }
180
+
181
+ invalidateOnBuild(): void {
182
+ throw new Error('MutableAsset.invalidateOnBuild()');
183
+ }
184
+ }
@@ -0,0 +1,94 @@
1
+ // @flow
2
+
3
+ import type {
4
+ Config as IPluginConfig,
5
+ DevDepOptions,
6
+ FilePath,
7
+ Environment,
8
+ FileCreateInvalidation,
9
+ ConfigResultWithFilePath,
10
+ PackageJSON,
11
+ } from '@atlaspack/types';
12
+
13
+ export type PluginConfigOptions = {|
14
+ isSource: boolean,
15
+ searchPath: FilePath,
16
+ env: Environment,
17
+ |};
18
+
19
+ export class PluginConfig implements IPluginConfig {
20
+ isSource: boolean;
21
+ searchPath: FilePath;
22
+ env: Environment;
23
+
24
+ constructor({env, isSource, searchPath}: PluginConfigOptions) {
25
+ this.env = env;
26
+ this.isSource = isSource;
27
+ this.searchPath = searchPath;
28
+ }
29
+
30
+ // eslint-disable-next-line no-unused-vars
31
+ invalidateOnFileChange(filePath: FilePath): void {
32
+ throw new Error('PluginOptions.invalidateOnFileChange');
33
+ }
34
+
35
+ // eslint-disable-next-line no-unused-vars
36
+ invalidateOnFileCreate(invalidations: FileCreateInvalidation): void {
37
+ throw new Error('PluginOptions.invalidateOnFileCreate');
38
+ }
39
+
40
+ // eslint-disable-next-line no-unused-vars
41
+ invalidateOnEnvChange(invalidation: string): void {
42
+ throw new Error('PluginOptions.invalidateOnEnvChange');
43
+ }
44
+
45
+ invalidateOnStartup(): void {
46
+ throw new Error('PluginOptions.invalidateOnStartup');
47
+ }
48
+
49
+ invalidateOnBuild(): void {
50
+ throw new Error('PluginOptions.invalidateOnBuild');
51
+ }
52
+
53
+ // eslint-disable-next-line no-unused-vars
54
+ addDevDependency(options: DevDepOptions): void {
55
+ throw new Error('PluginOptions.addDevDependency');
56
+ }
57
+
58
+ // eslint-disable-next-line no-unused-vars
59
+ setCacheKey(key: string): void {
60
+ throw new Error('PluginOptions.setCacheKey');
61
+ }
62
+
63
+ getConfig<T>(
64
+ // eslint-disable-next-line no-unused-vars
65
+ filePaths: Array<FilePath>,
66
+ // eslint-disable-next-line no-unused-vars
67
+ options?: {|
68
+ packageKey?: string,
69
+ parse?: boolean,
70
+ exclude?: boolean,
71
+ |},
72
+ ): Promise<?ConfigResultWithFilePath<T>> {
73
+ throw new Error('PluginOptions.getConfig');
74
+ }
75
+
76
+ getConfigFrom<T>(
77
+ // eslint-disable-next-line no-unused-vars
78
+ searchPath: FilePath,
79
+ // eslint-disable-next-line no-unused-vars
80
+ filePaths: Array<FilePath>,
81
+ // eslint-disable-next-line no-unused-vars
82
+ options?: {|
83
+ packageKey?: string,
84
+ parse?: boolean,
85
+ exclude?: boolean,
86
+ |},
87
+ ): Promise<?ConfigResultWithFilePath<T>> {
88
+ throw new Error('PluginOptions.getConfigFrom');
89
+ }
90
+
91
+ getPackage(): Promise<?PackageJSON> {
92
+ throw new Error('PluginOptions.getPackage');
93
+ }
94
+ }
@@ -0,0 +1,47 @@
1
+ // @flow
2
+
3
+ import type {PluginLogger as IPlguinLogger} from '@atlaspack/types';
4
+ import type {
5
+ Diagnostifiable,
6
+ DiagnosticWithoutOrigin,
7
+ } from '@atlaspack/diagnostic';
8
+
9
+ export class PluginLogger implements IPlguinLogger {
10
+ verbose(
11
+ diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
12
+ ): void {
13
+ // eslint-disable-next-line no-console
14
+ console.log(diagnostic);
15
+ }
16
+
17
+ info(
18
+ diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
19
+ ): void {
20
+ // eslint-disable-next-line no-console
21
+ console.info(diagnostic);
22
+ }
23
+
24
+ log(
25
+ diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
26
+ ): void {
27
+ // eslint-disable-next-line no-console
28
+ console.log(diagnostic);
29
+ }
30
+
31
+ warn(
32
+ diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>,
33
+ ): void {
34
+ // eslint-disable-next-line no-console
35
+ console.warn(diagnostic);
36
+ }
37
+
38
+ error(
39
+ input:
40
+ | Diagnostifiable
41
+ | DiagnosticWithoutOrigin
42
+ | Array<DiagnosticWithoutOrigin>,
43
+ ): void {
44
+ // eslint-disable-next-line no-console
45
+ console.error(input);
46
+ }
47
+ }
@@ -0,0 +1,137 @@
1
+ // @flow
2
+
3
+ import type {
4
+ PluginOptions as IPluginOptions,
5
+ LogLevel,
6
+ FileSystem,
7
+ PackageManager,
8
+ EnvMap,
9
+ FilePath,
10
+ HMROptions,
11
+ ServerOptions,
12
+ DetailedReportOptions,
13
+ BuildMode,
14
+ } from '@atlaspack/types';
15
+ import type {FeatureFlags} from '@atlaspack/feature-flags';
16
+
17
+ export class PluginOptions implements IPluginOptions {
18
+ #options: IPluginOptions;
19
+
20
+ get env(): EnvMap {
21
+ if (!('env' in this.#options)) {
22
+ return process.env;
23
+ // throw new Error('PluginOptions.env');
24
+ }
25
+ return this.#options.env;
26
+ }
27
+
28
+ get projectRoot(): FilePath {
29
+ if (!('projectRoot' in this.#options)) {
30
+ throw new Error('PluginOptions.projectRoot');
31
+ }
32
+ return this.#options.projectRoot;
33
+ }
34
+
35
+ get packageManager(): PackageManager {
36
+ if (!('packageManager' in this.#options)) {
37
+ throw new Error('PluginOptions.packageManager');
38
+ }
39
+ return this.#options.packageManager;
40
+ }
41
+
42
+ get mode(): BuildMode {
43
+ if (!('mode' in this.#options)) {
44
+ throw new Error('PluginOptions.mode');
45
+ }
46
+ return this.#options.mode;
47
+ }
48
+
49
+ get parcelVersion(): string {
50
+ if (!('parcelVersion' in this.#options)) {
51
+ return 'UNKNOWN VERSION';
52
+ // throw new Error('PluginOptions.parcelVersion');
53
+ }
54
+ return this.#options.parcelVersion;
55
+ }
56
+
57
+ get hmrOptions(): ?HMROptions {
58
+ if (!('hmrOptions' in this.#options)) {
59
+ throw new Error('PluginOptions.hmrOptions');
60
+ }
61
+ return this.#options.hmrOptions;
62
+ }
63
+
64
+ get serveOptions(): ServerOptions | false {
65
+ if (!('serveOptions' in this.#options)) {
66
+ throw new Error('PluginOptions.serveOptions');
67
+ }
68
+ return this.#options.serveOptions;
69
+ }
70
+
71
+ get shouldBuildLazily(): boolean {
72
+ if (!('shouldBuildLazily' in this.#options)) {
73
+ throw new Error('PluginOptions.shouldBuildLazily');
74
+ }
75
+ return this.#options.shouldBuildLazily;
76
+ }
77
+
78
+ get shouldAutoInstall(): boolean {
79
+ if (!('shouldAutoInstall' in this.#options)) {
80
+ throw new Error('PluginOptions.shouldAutoInstall');
81
+ }
82
+ return this.#options.shouldAutoInstall;
83
+ }
84
+
85
+ get logLevel(): LogLevel {
86
+ if (!('logLevel' in this.#options)) {
87
+ throw new Error('PluginOptions.logLevel');
88
+ }
89
+ return this.#options.logLevel;
90
+ }
91
+
92
+ get cacheDir(): string {
93
+ if (!('cacheDir' in this.#options)) {
94
+ throw new Error('PluginOptions.cacheDir');
95
+ }
96
+ return this.#options.cacheDir;
97
+ }
98
+
99
+ get inputFS(): FileSystem {
100
+ if (!('inputFS' in this.#options)) {
101
+ throw new Error('PluginOptions.inputFS');
102
+ }
103
+ return this.#options.inputFS;
104
+ }
105
+
106
+ get outputFS(): FileSystem {
107
+ if (!('outputFS' in this.#options)) {
108
+ throw new Error('PluginOptions.outputFS');
109
+ }
110
+ return this.#options.outputFS;
111
+ }
112
+
113
+ get instanceId(): string {
114
+ if (!('instanceId' in this.#options)) {
115
+ throw new Error('PluginOptions.instanceId');
116
+ }
117
+ return this.#options.instanceId;
118
+ }
119
+
120
+ get detailedReport(): ?DetailedReportOptions {
121
+ if (!('detailedReport' in this.#options)) {
122
+ throw new Error('PluginOptions.detailedReport');
123
+ }
124
+ return this.#options.detailedReport;
125
+ }
126
+
127
+ get featureFlags(): FeatureFlags {
128
+ if (!('featureFlags' in this.#options)) {
129
+ throw new Error('PluginOptions.featureFlags');
130
+ }
131
+ return this.#options.featureFlags;
132
+ }
133
+
134
+ constructor(options: $Partial<IPluginOptions>) {
135
+ this.#options = options;
136
+ }
137
+ }
@@ -0,0 +1,11 @@
1
+ // @flow
2
+
3
+ import type {PluginTracer as IPluginTracer} from '@atlaspack/types';
4
+
5
+ export class PluginTracer implements IPluginTracer {
6
+ enabled: false;
7
+
8
+ createMeasurement() {
9
+ throw new Error('PluginTracer.createMeasurement');
10
+ }
11
+ }
@@ -0,0 +1,27 @@
1
+ // @flow
2
+
3
+ import type {Target as NapiTarget} from '@atlaspack/rust';
4
+ import type {
5
+ Target as ClassicTarget,
6
+ FilePath,
7
+ Environment,
8
+ SourceLocation,
9
+ } from '@atlaspack/types';
10
+
11
+ export class Target implements ClassicTarget {
12
+ distEntry: ?FilePath;
13
+ distDir: FilePath;
14
+ env: Environment;
15
+ name: string;
16
+ publicUrl: string;
17
+ loc: ?SourceLocation;
18
+
19
+ constructor(inner: NapiTarget, env: Environment) {
20
+ this.distDir = inner.distDir;
21
+ this.distEntry = inner.distEntry;
22
+ this.name = inner.name;
23
+ this.publicUrl = inner.publicUrl;
24
+ this.loc = inner.loc;
25
+ this.env = env;
26
+ }
27
+ }