Skip to content

Commit

Permalink
chore(cli-bundler): switch to querystring-browser-stub and fs-browser…
Browse files Browse the repository at this point in the history
…-stub
  • Loading branch information
3cp committed May 28, 2020
1 parent ed4dbc6 commit 9bae069
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 19 deletions.
9 changes: 6 additions & 3 deletions lib/build/stub-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const UNAVAIABLE_CORE_MODULES = [
'cluster',
'dgram',
'dns',
'fs',
// 'fs',
'net',
'readline',
'repl',
Expand Down Expand Up @@ -50,8 +50,11 @@ module.exports = function(moduleId, root) {
}

if (moduleId === 'querystring') {
// using querystring-es3 next version 1.0.0-0
return {name: 'querystring', path: resolvePath('querystring-es3', root)};
return {name: 'querystring', path: resolvePath('querystring-browser-stub', root)};
}

if (moduleId === 'fs') {
return {name: 'fs', path: resolvePath('fs-browser-stub', root)};
}

if (moduleId === 'sys') {
Expand Down
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
"url": "https://github.com/aurelia/cli"
},
"dependencies": {
"@babel/core": "^7.9.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/plugin-transform-modules-amd": "^7.9.6",
"@babel/plugin-transform-modules-commonjs": "^7.9.6",
"@babel/register": "^7.9.0",
"@babel/core": "^7.10.1",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-proposal-decorators": "^7.10.1",
"@babel/plugin-transform-modules-amd": "^7.10.1",
"@babel/plugin-transform-modules-commonjs": "^7.10.1",
"@babel/register": "^7.10.1",
"ansi-colors": "^4.1.1",
"assert": "^2.0.0",
"aurelia-dependency-injection": "^1.5.2",
Expand All @@ -57,10 +57,11 @@
"convert-source-map": "^1.7.0",
"crypto-browserify": "^3.12.0",
"del": "^5.1.0",
"domain-browser": "^4.0.0",
"domain-browser": "^4.4.0",
"enquirer": "^2.3.5",
"esprima": "^4.0.1",
"events": "^3.1.0",
"fs-browser-stub": "^1.0.1",
"gulp": "^4.0.2",
"htmlparser2": "^4.1.0",
"https-browserify": "^1.0.0",
Expand All @@ -72,31 +73,31 @@
"path-browserify": "1.0.1",
"process": "^0.11.10",
"punycode": "^2.1.1",
"querystring-es3": "1.0.0-0",
"querystring-browser-stub": "^1.0.0",
"readable-stream": "^3.6.0",
"resolve": "^1.17.0",
"semver": "^7.3.2",
"stream-browserify": "^3.0.0",
"stream-http": "^3.1.0",
"stream-http": "^3.1.1",
"string_decoder": "^1.3.0",
"terser": "^4.6.12",
"terser": "^4.7.0",
"timers-browserify": "^2.0.11",
"tty-browserify": "0.0.1",
"typescript": "^3.8.3",
"typescript": "^3.9.3",
"url": "^0.11.0",
"util": "^0.12.2",
"util": "^0.12.3",
"vm-browserify": "^1.1.2"
},
"devDependencies": {
"@types/node": "^13.13.4",
"@types/node": "^14.0.5",
"babel-eslint": "^10.1.0",
"gulp-bump": "^3.1.3",
"gulp-conventional-changelog": "^2.0.29",
"gulp-conventional-changelog": "^2.0.32",
"gulp-eslint": "^6.0.0",
"jasmine": "^3.5.0",
"jasmine-spec-reporter": "^5.0.2",
"mock-fs": "^4.12.0",
"nodemon": "^2.0.3",
"nodemon": "^2.0.4",
"nyc": "^15.0.1",
"yargs": "^15.3.1"
}
Expand Down
41 changes: 40 additions & 1 deletion spec/lib/build/stub-module.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,50 @@ describe('StubCoreNodejsModule', () => {
});
});

it('stubs domain', () => {
expect(stubModule('domain', 'src')).toEqual({
name: 'domain',
path: '../node_modules/domain-browser'
});
});

it('stubs http', () => {
expect(stubModule('http', 'src')).toEqual({
name: 'http',
path: '../node_modules/stream-http'
});
});

it('stubs querystring', () => {
expect(stubModule('querystring', 'src')).toEqual({
name: 'querystring',
path: '../node_modules/querystring-browser-stub'
});
});

it('stubs fs', () => {
expect(stubModule('fs', 'src')).toEqual({
name: 'fs',
path: '../node_modules/fs-browser-stub'
});
});

it('ignores sys', () => {
expect(stubModule('sys', 'src')).toBeUndefined();
});

it('stubModule stubs zlib', () => {
expect(stubModule('zlib', 'src')).toEqual({
name: 'zlib',
path: '../node_modules/browserify-zlib'
});
});

it('stubs empty module for some core module', () => {
expect(stubModule('fs', 'src')).toBe('define(function(){});');
expect(stubModule('dns', 'src')).toBe('define(function(){});');
});

it('stubs empty module for __ignore__', () => {
expect(stubModule('__ignore__', 'src')).toBe('define(function(){});');
});
});

0 comments on commit 9bae069

Please sign in to comment.