@deot/dev-builder 2.5.4 → 2.6.1

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/index.cjs CHANGED
@@ -22,6 +22,7 @@ const cssnano = require('cssnano');
22
22
  const autoprefixer = require('autoprefixer');
23
23
  const apiExtractor = require('@microsoft/api-extractor');
24
24
 
25
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
25
26
  function _interopNamespaceDefault(e) {
26
27
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
27
28
  if (e) {
@@ -43,7 +44,7 @@ const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
43
44
  const fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs$1);
44
45
  const sass__namespace = /*#__PURE__*/_interopNamespaceDefault(sass);
45
46
 
46
- const dirname$1 = path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))));
47
+ const dirname$1 = path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
47
48
  const run$3 = async (options) => {
48
49
  const locals = devShared.Locals.impl();
49
50
  const { cwd, workspace } = locals;
@@ -63,9 +64,9 @@ const run$3 = async (options) => {
63
64
  let files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
64
65
  if (!files.length)
65
66
  return stats;
66
- const build = async (format) => {
67
+ const build = async (format, filepath) => {
67
68
  const buildOptions = {
68
- files,
69
+ files: [filepath],
69
70
  format,
70
71
  external,
71
72
  globals,
@@ -96,38 +97,38 @@ const run$3 = async (options) => {
96
97
  options$ = isVuePackage ? vite.mergeConfig(sharedVueConfig, options$) : isReactPackage ? vite.mergeConfig(sharedReactConfig, options$) : options$;
97
98
  }
98
99
  process.env.BUILD_OPTIONS = encodeURIComponent(JSON.stringify(buildOptions));
99
- let viteBuild = await vite.build(options$);
100
- return viteBuild;
100
+ let outputs2 = await vite.build(options$);
101
+ outputs2.forEach((i) => {
102
+ i.output.forEach((j) => {
103
+ if (j.type === "asset") {
104
+ let fileName = filepath.replace(/^(.*)((\..*\.js)|\.cjs|\.ts)/, `$1.${j.fileName}`);
105
+ fs.outputFileSync(`${outDir}/${fileName}`, j.source);
106
+ return;
107
+ }
108
+ if (j.type === "chunk") {
109
+ fs.outputFileSync(`${outDir}/${j.fileName}`, j.code);
110
+ return;
111
+ }
112
+ });
113
+ });
114
+ return outputs2;
101
115
  };
102
116
  const formats = scriptFormats.split(",").filter((i) => {
103
117
  return !isNodePackage || ["es", "cjs"].includes(i);
104
118
  });
105
- await formats.reduce(
106
- (preProcess, format) => {
107
- preProcess = preProcess.then(() => build(format)).then((outputs2) => {
108
- outputs2.forEach((i) => {
109
- i.output.forEach((j) => {
110
- if (j.type === "asset") {
111
- fs.outputFileSync(`${outDir}/${j.fileName}`, j.source);
112
- return;
113
- }
114
- if (j.type === "chunk") {
115
- fs.outputFileSync(`${outDir}/${j.name}.${format}${format === "cjs" ? "" : ".js"}`, j.code);
116
- return;
117
- }
118
- });
119
- });
120
- });
121
- return preProcess;
122
- },
123
- Promise.resolve()
124
- );
125
- let outputs = fs.readdirSync(outDir).filter((i) => /^index(.*)(?!=\.d)\.c?js$/.test(i));
119
+ let serial = Promise.resolve();
120
+ formats.forEach((format) => {
121
+ files.forEach((filepath) => {
122
+ serial = serial.then(() => build(format, filepath));
123
+ });
124
+ });
125
+ await serial;
126
+ let outputs = fs.readdirSync(outDir).filter((i) => /^index(.*)(?!=(\.d))\.(cjs|js|style\.css)$/.test(i));
126
127
  outputs.forEach((file) => {
127
128
  let stat = fs.statSync(path__namespace.resolve(outDir, file));
128
129
  stats.push({
129
- file: file.replace(/^(.*)((\..*\.js)|\.cjs)/, "$1.ts"),
130
- format: file.replace(/(.*\.(.*)\.js|.*\.(cjs))/, "$2$3"),
130
+ file: file.replace(/^(.*)(\.umd\.cjs|\.iife\.js)/, "$1.ts").replace(/^(.*)(\.js|\.cjs)/, "$1.ts"),
131
+ format: /\.style\.css$/.test(file) ? "css" : /\.umd\.cjs$/.test(file) ? "umd" : /\.cjs$/.test(file) ? "cjs" : /\.iife\.js$/.test(file) ? "iife" : "es",
131
132
  size: stat.size
132
133
  });
133
134
  });
@@ -161,7 +162,7 @@ const run$2 = async (options) => {
161
162
  return stats;
162
163
  };
163
164
 
164
- const dirname = path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))));
165
+ const dirname = path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
165
166
  const run$1 = async (options) => {
166
167
  const { workspace, packageDir: packageRootDir } = devShared.Locals.impl();
167
168
  const { isVuePackage, packageDir, packageOutDir, packageSourceDir, packageOptions, commandOptions } = options;
@@ -38,9 +38,9 @@ const run$3 = async (options) => {
38
38
  let files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
39
39
  if (!files.length)
40
40
  return stats;
41
- const build = async (format) => {
41
+ const build = async (format, filepath) => {
42
42
  const buildOptions = {
43
- files,
43
+ files: [filepath],
44
44
  format,
45
45
  external,
46
46
  globals,
@@ -71,38 +71,38 @@ const run$3 = async (options) => {
71
71
  options$ = isVuePackage ? mergeConfig(sharedVueConfig, options$) : isReactPackage ? mergeConfig(sharedReactConfig, options$) : options$;
72
72
  }
73
73
  process.env.BUILD_OPTIONS = encodeURIComponent(JSON.stringify(buildOptions));
74
- let viteBuild = await build$1(options$);
75
- return viteBuild;
74
+ let outputs2 = await build$1(options$);
75
+ outputs2.forEach((i) => {
76
+ i.output.forEach((j) => {
77
+ if (j.type === "asset") {
78
+ let fileName = filepath.replace(/^(.*)((\..*\.js)|\.cjs|\.ts)/, `$1.${j.fileName}`);
79
+ fs$1.outputFileSync(`${outDir}/${fileName}`, j.source);
80
+ return;
81
+ }
82
+ if (j.type === "chunk") {
83
+ fs$1.outputFileSync(`${outDir}/${j.fileName}`, j.code);
84
+ return;
85
+ }
86
+ });
87
+ });
88
+ return outputs2;
76
89
  };
77
90
  const formats = scriptFormats.split(",").filter((i) => {
78
91
  return !isNodePackage || ["es", "cjs"].includes(i);
79
92
  });
80
- await formats.reduce(
81
- (preProcess, format) => {
82
- preProcess = preProcess.then(() => build(format)).then((outputs2) => {
83
- outputs2.forEach((i) => {
84
- i.output.forEach((j) => {
85
- if (j.type === "asset") {
86
- fs$1.outputFileSync(`${outDir}/${j.fileName}`, j.source);
87
- return;
88
- }
89
- if (j.type === "chunk") {
90
- fs$1.outputFileSync(`${outDir}/${j.name}.${format}${format === "cjs" ? "" : ".js"}`, j.code);
91
- return;
92
- }
93
- });
94
- });
95
- });
96
- return preProcess;
97
- },
98
- Promise.resolve()
99
- );
100
- let outputs = fs$1.readdirSync(outDir).filter((i) => /^index(.*)(?!=\.d)\.c?js$/.test(i));
93
+ let serial = Promise.resolve();
94
+ formats.forEach((format) => {
95
+ files.forEach((filepath) => {
96
+ serial = serial.then(() => build(format, filepath));
97
+ });
98
+ });
99
+ await serial;
100
+ let outputs = fs$1.readdirSync(outDir).filter((i) => /^index(.*)(?!=(\.d))\.(cjs|js|style\.css)$/.test(i));
101
101
  outputs.forEach((file) => {
102
102
  let stat = fs$1.statSync(path.resolve(outDir, file));
103
103
  stats.push({
104
- file: file.replace(/^(.*)((\..*\.js)|\.cjs)/, "$1.ts"),
105
- format: file.replace(/(.*\.(.*)\.js|.*\.(cjs))/, "$2$3"),
104
+ file: file.replace(/^(.*)(\.umd\.cjs|\.iife\.js)/, "$1.ts").replace(/^(.*)(\.js|\.cjs)/, "$1.ts"),
105
+ format: /\.style\.css$/.test(file) ? "css" : /\.umd\.cjs$/.test(file) ? "umd" : /\.cjs$/.test(file) ? "cjs" : /\.iife\.js$/.test(file) ? "iife" : "es",
106
106
  size: stat.size
107
107
  });
108
108
  });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@deot/dev-builder",
3
- "version": "2.5.4",
3
+ "version": "2.6.1",
4
4
  "type": "module",
5
- "main": "dist/index.es.js",
5
+ "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/index.es.js",
9
+ "import": "./dist/index.js",
10
10
  "require": "./dist/index.cjs",
11
11
  "types": "./dist/index.d.ts"
12
12
  }
@@ -29,21 +29,21 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@deot/dev-react": "^2.5.1",
33
- "@deot/dev-shared": "^2.5.0",
34
- "@deot/dev-vue": "^2.5.1",
35
- "@microsoft/api-extractor": "^7.36.4",
36
- "autoprefixer": "^10.4.15",
32
+ "@deot/dev-react": "^2.6.0",
33
+ "@deot/dev-shared": "^2.6.0",
34
+ "@deot/dev-vue": "^2.6.0",
35
+ "@microsoft/api-extractor": "^7.38.1",
36
+ "autoprefixer": "^10.4.16",
37
37
  "chalk": "^5.3.0",
38
38
  "cssnano": "^6.0.1",
39
39
  "fs-extra": "^11.1.1",
40
40
  "ora": "^7.0.1",
41
- "postcss": "^8.4.29",
41
+ "postcss": "^8.4.31",
42
42
  "postcss-flexbugs-fixes": "^5.0.2",
43
43
  "postcss-import": "^15.1.0",
44
44
  "postcss-url": "^10.1.3",
45
- "sass": "^1.66.1",
46
- "vite": "^4.4.9"
45
+ "sass": "^1.69.5",
46
+ "vite": "^4.5.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "typescript": "^5.1.6"