@atls/code-service 2.0.4 → 2.0.8

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.
package/dist/service.js CHANGED
@@ -22,15 +22,9 @@ export class Service extends EventEmitter {
22
22
  }
23
23
  async build() {
24
24
  const compiler = this.webpack(await this.config.build('production', [
25
- {
26
- name: 'progress',
27
- use: this.webpack.ProgressPlugin,
28
- args: [
29
- (percent, message) => {
30
- this.emit('build:progress', { percent: percent * 100, message });
31
- },
32
- ],
33
- },
25
+ new this.webpack.ProgressPlugin((percent, message) => {
26
+ this.emit('build:progress', { percent: percent * 100, message });
27
+ }),
34
28
  ]));
35
29
  return new Promise((resolve, reject) => {
36
30
  compiler.run((error, stats) => {
@@ -73,25 +67,10 @@ export class Service extends EventEmitter {
73
67
  });
74
68
  });
75
69
  return this.webpack(await this.config.build('development', [
76
- {
77
- name: 'start-server',
78
- use: StartServerPlugin,
79
- args: [
80
- {
81
- stdout: pass,
82
- stderr: pass,
83
- },
84
- ],
85
- },
86
- {
87
- name: 'progress',
88
- use: this.webpack.ProgressPlugin,
89
- args: [
90
- (percent, message) => {
91
- this.emit('build:progress', { percent: percent * 100, message });
92
- },
93
- ],
94
- },
70
+ new StartServerPlugin({ stdout: pass, stderr: pass }),
71
+ new this.webpack.ProgressPlugin((percent, message) => {
72
+ this.emit('build:progress', { percent: percent * 100, message });
73
+ }),
95
74
  ])).watch({}, (error, stats) => {
96
75
  this.emit('end', { error, stats });
97
76
  if (error) {
@@ -1,5 +1,5 @@
1
+ import type { webpack as wp } from '@atls/code-runtime/webpack';
1
2
  import type { WebpackEnvironment } from './webpack.interfaces.js';
2
- import { webpack as wp } from '@atls/code-runtime/webpack';
3
3
  export declare class WebpackConfig {
4
4
  private readonly webpack;
5
5
  private readonly loaders;
@@ -9,11 +9,7 @@ export declare class WebpackConfig {
9
9
  nodeLoader: string;
10
10
  nullLoader: string;
11
11
  }, cwd: string);
12
- build(environment?: WebpackEnvironment, additionalPlugins?: Array<{
13
- use: wp.WebpackPluginInstance;
14
- args: Array<any>;
15
- name: string;
16
- }>): Promise<wp.Configuration>;
12
+ build(environment?: WebpackEnvironment, additionalPlugins?: Array<wp.WebpackPluginInstance>): Promise<wp.Configuration>;
17
13
  private getWorkspaceType;
18
14
  private createPlugins;
19
15
  }
@@ -3,10 +3,6 @@ import { writeFile } from 'node:fs/promises';
3
3
  import { mkdtemp } from 'node:fs/promises';
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
- import { webpack as wp } from '@atls/code-runtime/webpack';
7
- import { tsLoaderPath } from '@atls/code-runtime/webpack';
8
- import { nodeLoaderPath } from '@atls/code-runtime/webpack';
9
- import { nullLoaderPath } from '@atls/code-runtime/webpack';
10
6
  import tsconfig from '@atls/config-typescript';
11
7
  import { WebpackExternals } from './webpack.externals.js';
12
8
  import { LAZY_IMPORTS } from './webpack.ignore.js';
@@ -39,14 +35,13 @@ export class WebpackConfig {
39
35
  index: join(this.cwd, 'src/index'),
40
36
  ...(environment === 'development' && { hot: 'webpack/hot/poll?100' }),
41
37
  },
42
- node: { __dirname: false, __filename: false },
38
+ node: { __dirname: true, __filename: false },
43
39
  output: {
44
40
  path: join(this.cwd, 'dist'),
45
41
  filename: '[name].js',
46
42
  library: { type },
47
43
  chunkFormat: environment === 'development' ? 'commonjs' : type,
48
44
  module: type === 'module',
49
- publicPath: './',
50
45
  clean: false,
51
46
  assetModuleFilename: 'assets/[name][ext]',
52
47
  },
@@ -73,13 +68,13 @@ export class WebpackConfig {
73
68
  {
74
69
  test: /\.d\.ts$/,
75
70
  use: {
76
- loader: nullLoaderPath,
71
+ loader: this.loaders.nullLoader,
77
72
  },
78
73
  },
79
74
  {
80
75
  test: /(^.?|\.[^d]|[^.]d|[^.][^d])\.tsx?$/,
81
76
  use: {
82
- loader: tsLoaderPath,
77
+ loader: this.loaders.tsLoader,
83
78
  options: {
84
79
  transpileOnly: true,
85
80
  experimentalWatchApi: true,
@@ -93,7 +88,7 @@ export class WebpackConfig {
93
88
  { test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource' },
94
89
  { test: /\.(png|svg|jpg|jpeg|gif)$/i, type: 'asset/resource' },
95
90
  { test: /\.(md)$/i, type: 'asset/resource' },
96
- { test: /\.node$/, use: nodeLoaderPath },
91
+ { test: /\.node$/, use: this.loaders.nodeLoader },
97
92
  ],
98
93
  },
99
94
  };
@@ -110,7 +105,7 @@ export class WebpackConfig {
110
105
  }
111
106
  createPlugins(environment, additionalPlugins) {
112
107
  const plugins = [
113
- new wp.IgnorePlugin({
108
+ new this.webpack.IgnorePlugin({
114
109
  checkResource: (resource) => {
115
110
  if (resource.endsWith('.js.map')) {
116
111
  return true;
@@ -132,7 +127,11 @@ export class WebpackConfig {
132
127
  ...additionalPlugins,
133
128
  ];
134
129
  if (environment === 'development') {
135
- plugins.push(new wp.HotModuleReplacementPlugin());
130
+ plugins.push(new this.webpack.HotModuleReplacementPlugin());
131
+ plugins.push(new this.webpack.BannerPlugin({
132
+ banner: `import { createRequire } from 'node:module'\nimport { fileURLToPath } from 'node:url'\nconst require = createRequire(import.meta.url)\nconst __filename = fileURLToPath(import.meta.url)\n`,
133
+ raw: true,
134
+ }));
136
135
  }
137
136
  return plugins;
138
137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atls/code-service",
3
- "version": "2.0.4",
3
+ "version": "2.0.8",
4
4
  "license": "BSD-3-Clause",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@atls/code-configuration": "2.0.0",
26
- "@atls/code-runtime": "2.0.4",
26
+ "@atls/code-runtime": "2.0.8",
27
27
  "@atls/config-typescript": "2.0.1",
28
28
  "@atls/webpack-start-server-plugin": "1.0.0",
29
29
  "@yarnpkg/cli": "4.5.1",