quackage 1.0.62 → 1.0.63
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.
|
@@ -70,7 +70,13 @@ console.log(` > Building to [${_CONFIG.LibraryUniminifiedFileName}] and [${_CO
|
|
|
70
70
|
console.log(`--> Gulp is taking over!`);
|
|
71
71
|
|
|
72
72
|
const libBrowserify = require('browserify');
|
|
73
|
-
|
|
73
|
+
|
|
74
|
+
// Resolve gulp from the consuming project's CWD so that the task
|
|
75
|
+
// registry is shared with the gulp CLI (which also resolves from CWD).
|
|
76
|
+
// Without this, `file:` dev-dependency references to quackage cause
|
|
77
|
+
// two separate gulp instances — tasks registered here become invisible
|
|
78
|
+
// to the CLI, resulting in "Task never defined: default".
|
|
79
|
+
const libGulp = require(require.resolve('gulp', { paths: [process.cwd()] }));
|
|
74
80
|
|
|
75
81
|
const libVinylSourceStream = require('vinyl-source-stream');
|
|
76
82
|
const libVinylBuffer = require('vinyl-buffer');
|
|
@@ -78,28 +84,74 @@ const libVinylBuffer = require('vinyl-buffer');
|
|
|
78
84
|
const libSourcemaps = require('gulp-sourcemaps');
|
|
79
85
|
const libBabel = require('gulp-babel');
|
|
80
86
|
const libTerser = require('gulp-terser');
|
|
87
|
+
const { Transform } = require('stream');
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Create a configured browserify instance with common settings.
|
|
91
|
+
*
|
|
92
|
+
* Applies:
|
|
93
|
+
* - BrowserifyIgnore entries from config
|
|
94
|
+
* - Global transform to rewrite `require('node:xxx')` → `require('xxx')`
|
|
95
|
+
* (needed for packages like find-my-way v9 that use Node.js prefixed builtins)
|
|
96
|
+
*
|
|
97
|
+
* @param {object} pConfig - The gulpfile config object
|
|
98
|
+
* @returns {object} Configured browserify instance
|
|
99
|
+
*/
|
|
100
|
+
function createBrowserifyInstance(pConfig)
|
|
101
|
+
{
|
|
102
|
+
var tmpBrowserify = libBrowserify(
|
|
103
|
+
{
|
|
104
|
+
entries: pConfig.EntrypointInputSourceFile,
|
|
105
|
+
standalone: pConfig.LibraryObjectName,
|
|
106
|
+
debug: true
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Ignore modules that should not be bundled (e.g. WASM loaders loaded via <script> tag)
|
|
110
|
+
if (Array.isArray(pConfig.BrowserifyIgnore))
|
|
111
|
+
{
|
|
112
|
+
for (var i = 0; i < pConfig.BrowserifyIgnore.length; i++)
|
|
113
|
+
{
|
|
114
|
+
tmpBrowserify.ignore(pConfig.BrowserifyIgnore[i]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Global transform: rewrite require('node:xxx') → require('xxx')
|
|
119
|
+
// Some npm packages (e.g. find-my-way v9) use the `node:` prefix for
|
|
120
|
+
// built-in modules, which browserify cannot resolve. This transform
|
|
121
|
+
// strips the prefix so browserify resolves the standard module name.
|
|
122
|
+
tmpBrowserify.transform(
|
|
123
|
+
function(pFile)
|
|
124
|
+
{
|
|
125
|
+
var tmpChunks = [];
|
|
126
|
+
return new Transform(
|
|
127
|
+
{
|
|
128
|
+
transform: function(pChunk, pEncoding, fCallback)
|
|
129
|
+
{
|
|
130
|
+
tmpChunks.push(pChunk);
|
|
131
|
+
fCallback();
|
|
132
|
+
},
|
|
133
|
+
flush: function(fCallback)
|
|
134
|
+
{
|
|
135
|
+
var tmpSource = Buffer.concat(tmpChunks).toString('utf8');
|
|
136
|
+
tmpSource = tmpSource.replace(
|
|
137
|
+
/require\(\s*['"]node:([^'"]+)['"]\s*\)/g,
|
|
138
|
+
"require('$1')"
|
|
139
|
+
);
|
|
140
|
+
this.push(tmpSource);
|
|
141
|
+
fCallback();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
{ global: true }
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
return tmpBrowserify;
|
|
149
|
+
}
|
|
81
150
|
|
|
82
151
|
// Build the module for the browser
|
|
83
152
|
libGulp.task('minified',
|
|
84
153
|
() => {
|
|
85
|
-
|
|
86
|
-
var tmpBrowserify = libBrowserify(
|
|
87
|
-
{
|
|
88
|
-
entries: _CONFIG.EntrypointInputSourceFile,
|
|
89
|
-
standalone: _CONFIG.LibraryObjectName,
|
|
90
|
-
debug: true
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Ignore modules that should not be bundled (e.g. WASM loaders loaded via <script> tag)
|
|
94
|
-
if (Array.isArray(_CONFIG.BrowserifyIgnore))
|
|
95
|
-
{
|
|
96
|
-
for (var i = 0; i < _CONFIG.BrowserifyIgnore.length; i++)
|
|
97
|
-
{
|
|
98
|
-
tmpBrowserify.ignore(_CONFIG.BrowserifyIgnore[i]);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return tmpBrowserify.bundle()
|
|
154
|
+
return createBrowserifyInstance(_CONFIG).bundle()
|
|
103
155
|
.pipe(libVinylSourceStream(_CONFIG.LibraryMinifiedFileName))
|
|
104
156
|
.pipe(libVinylBuffer())
|
|
105
157
|
.pipe(libSourcemaps.init({loadMaps: true}))
|
|
@@ -114,24 +166,7 @@ libGulp.task('minified',
|
|
|
114
166
|
// Build the module for the browser
|
|
115
167
|
libGulp.task('debug',
|
|
116
168
|
() => {
|
|
117
|
-
|
|
118
|
-
var tmpBrowserify = libBrowserify(
|
|
119
|
-
{
|
|
120
|
-
entries: _CONFIG.EntrypointInputSourceFile,
|
|
121
|
-
standalone: _CONFIG.LibraryObjectName,
|
|
122
|
-
debug: true
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// Ignore modules that should not be bundled (e.g. WASM loaders loaded via <script> tag)
|
|
126
|
-
if (Array.isArray(_CONFIG.BrowserifyIgnore))
|
|
127
|
-
{
|
|
128
|
-
for (var i = 0; i < _CONFIG.BrowserifyIgnore.length; i++)
|
|
129
|
-
{
|
|
130
|
-
tmpBrowserify.ignore(_CONFIG.BrowserifyIgnore[i]);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return tmpBrowserify.bundle()
|
|
169
|
+
return createBrowserifyInstance(_CONFIG).bundle()
|
|
135
170
|
.pipe(libVinylSourceStream(_CONFIG.LibraryUniminifiedFileName))
|
|
136
171
|
.pipe(libVinylBuffer())
|
|
137
172
|
.pipe(libSourcemaps.init({loadMaps: true}))
|
package/package.json
CHANGED
|
@@ -69,7 +69,15 @@ class QuackageCommandBuild extends libCommandLineCommand
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// ## .gulpfile-quackage-config.json
|
|
72
|
-
|
|
72
|
+
let tmpGulpfileConfigContent = this.fable.parseTemplateByHash('Gulpfile-Configuration', pAction);
|
|
73
|
+
// Allow per-action BrowserifyIgnore overrides from GulpExecutions entries
|
|
74
|
+
if (Array.isArray(pAction.BrowserifyIgnore) && pAction.BrowserifyIgnore.length > 0)
|
|
75
|
+
{
|
|
76
|
+
let tmpGulpfileConfig = JSON.parse(tmpGulpfileConfigContent);
|
|
77
|
+
tmpGulpfileConfig.BrowserifyIgnore = pAction.BrowserifyIgnore;
|
|
78
|
+
tmpGulpfileConfigContent = JSON.stringify(tmpGulpfileConfig, null, 4);
|
|
79
|
+
}
|
|
80
|
+
libFS.writeFileSync(`${this.fable.AppData.CWD}/.gulpfile-quackage-config.json`, tmpGulpfileConfigContent);
|
|
73
81
|
// ## .gulpfile-quackage.js
|
|
74
82
|
libFS.writeFileSync(`${this.fable.AppData.CWD}/.gulpfile-quackage.js`, this.fable.parseTemplateByHash('Gulpfile-QuackageBase', { AppData: this.fable.AppData, Record: pAction }));
|
|
75
83
|
// ## gulpfile.js
|