Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the Dll context #4961

Merged
merged 1 commit into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ eof-newline:
buildtools/test-eof-newline

.PHONY: test
test: .build/node_modules.timestamp build-dll
test: .build/node_modules.timestamp .build/build-dll.timestamp
TS_NODE_PROJECT=disable.json ./node_modules/karma/bin/karma start karma-conf.js --single-run

.PHONY: test-debug
test-debug: .build/node_modules.timestamp .build/node_modules_karma-chrome-launcher.timestamp
test-debug: .build/node_modules.timestamp .build/build-dll.timestamp .build/node_modules_karma-chrome-launcher.timestamp
TS_NODE_PROJECT=disable.json ./node_modules/karma/bin/karma start karma-conf.js --browsers=Chrome --single-run=false --autoWatch=true --debug

.build/node_modules_karma-chrome-launcher.timestamp:
Expand All @@ -159,15 +159,15 @@ test-debug: .build/node_modules.timestamp .build/node_modules_karma-chrome-launc
touch $@

.PHONY: serve-ngeo
serve-ngeo: .build/node_modules.timestamp build-dll $(ANGULAR_LOCALES_FILES)
serve-ngeo: .build/node_modules.timestamp .build/build-dll.timestamp $(ANGULAR_LOCALES_FILES)
npm run serve-ngeo-examples

.PHONY: serve-gmf
serve-gmf: .build/node_modules.timestamp build-dll $(ANGULAR_LOCALES_FILES)
serve-gmf: .build/node_modules.timestamp .build/build-dll.timestamp $(ANGULAR_LOCALES_FILES)
npm run serve-gmf-examples

.PHONY: serve-gmf-apps
serve-gmf-apps: .build/node_modules.timestamp build-dll $(ANGULAR_LOCALES_FILES)
serve-gmf-apps: .build/node_modules.timestamp .build/build-dll.timestamp $(ANGULAR_LOCALES_FILES)
npm run serve-gmf-apps

.PHONY: examples-hosted
Expand All @@ -180,23 +180,23 @@ examples-hosted: \
examples-hosted-ngeo: .build/examples-ngeo.timestamp .build/examples-hosted/index.html

.build/examples-ngeo.timestamp: $(NGEO_ALL_SRC_FILES) $(WEBPACK_CONFIG_FILES) \
.build/node_modules.timestamp build-dll
.build/node_modules.timestamp .build/build-dll.timestamp
npm run build-ngeo-examples
touch $@

.PHONY: examples-hosted-gmf
examples-hosted-gmf: .build/examples-gmf.timestamp .build/examples-hosted/contribs/gmf/index.html

.build/examples-gmf.timestamp: $(GMF_ALL_SRC_FILES) $(WEBPACK_CONFIG_FILES) \
.build/node_modules.timestamp build-dll
.build/node_modules.timestamp .build/build-dll.timestamp
npm run build-gmf-examples
touch $@

.PHONY: examples-hosted-apps
examples-hosted-apps: .build/gmf-apps.timestamp .build/examples-hosted-gmf-apps-deps.timestamp

.build/gmf-apps.timestamp: $(GMF_APPS_ALL_SRC_FILES) $(WEBPACK_CONFIG_FILES) \
.build/node_modules.timestamp build-dll
.build/node_modules.timestamp .build/build-dll.timestamp
npm run build-gmf-apps
touch $@

Expand All @@ -218,21 +218,25 @@ gh-pages: .build/python-venv.timestamp
touch $@

.build/examples-hosted-gmf-apps-deps.timestamp: \
.build/build-dll.timestamp \
$(addprefix contribs/gmf/build/gmf-, $(addsuffix .json, $(LANGUAGES))) \
$(addprefix contribs/gmf/build/angular-locale_, $(addsuffix .js, $(LANGUAGES)))
mkdir -p .build/examples-hosted/contribs/gmf
# We need the files for each app
# To simplify processing, we first copy them in gmfappsdeps directory, then from there to each app
$(foreach f,$^,mkdir -p .build/examples-hosted/gmfappsdeps/`dirname $(f)`; cp $(f) .build/examples-hosted/gmfappsdeps/$(f);)
rsync --recursive .build/examples-hosted/gmfappsdeps/contribs/gmf/ .build/examples-hosted/contribs/gmf/apps/;)
cp -r dist .build/examples-hosted/
touch $@

.build/examples-hosted/index.html: \
buildtools/examples-index.mako.html \
$(NGEO_EXAMPLES_HTML_FILES) \
.build/python-venv.timestamp
mkdir -p $(dir $@)
$(PY_VENV_BIN)/python buildtools/generate-examples-index.py $< $(NGEO_EXAMPLES_HTML_FILES) > $@
$(PY_VENV_BIN)/python buildtools/generate-examples-index.py \
--app 'GeoMapFish' contribs/gmf/mobile.html 'GeoMapFish examples.' \
$< $(NGEO_EXAMPLES_HTML_FILES) > $@

.build/examples-hosted/contribs/gmf/index.html: \
buildtools/examples-index.mako.html \
Expand Down Expand Up @@ -388,10 +392,14 @@ contribs/gmf/build/gmf-%.json: \


.PHONY: build-dll
build-dll:.build/python-venv.timestamp
build-dll: .build/build-dll.timestamp

.build/build-dll.timestamp: .build/python-venv.timestamp
$(PY_VENV_BIN)/python3 buildtools/extract-ngeo-dependencies > deps.js && \
npm run build-dll
rm deps.js
mkdir -p $(dir $@)
touch $@

.PHONY: clean
clean:
Expand Down
179 changes: 90 additions & 89 deletions buildtools/webpack.commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,106 +4,107 @@ const SassPlugin = require('./webpack.plugin.js');

const devMode = process.env.NODE_ENV !== 'production';

module.exports = function(config) {

const dllPlugin = new webpack.DllReferencePlugin({
manifest: path.resolve(__dirname, '../dist/vendor-manifest.json'),
context: path.resolve(__dirname, '../context/jjjj')
});


const providePlugin = new webpack.ProvidePlugin({
// Make sure that Angular finds jQuery and does not fall back to jqLite
// See https://github.com/webpack/webpack/issues/582
'window.jQuery': 'jquery',
// For Bootstrap
'jQuery': 'jquery',
// For own scripts
$: 'jquery',
});

const babelPresets = [[require.resolve('@babel/preset-env'), {
'targets': {
'browsers': ['last 2 versions', 'Firefox ESR', 'ie 11'],
},
'modules': false,
'loose': true,
}]];

const angularRule = {
test: require.resolve('angular'),
use: {
loader: 'expose-loader',
options: 'angular'
}
};
config = config || {};

// Expose corejs-typeahead as window.Bloodhound
const typeaheadRule = {
test: require.resolve('corejs-typeahead'),
use: {
loader: 'expose-loader',
options: 'Bloodhound'
}
};
const dllPlugin = new webpack.DllReferencePlugin(Object.assign({
manifest: path.resolve(__dirname, '../dist/vendor-manifest.json')
}, config.DllReferencePluginOptions || {}));

const cssRule = {
test: /\.css$/,
use: [
'./buildtools/webpack.scss-loader',
'extract-loader',
'css-loader',
]
};

const sassRule = {
test: /\.scss$/,
use: [{
loader: './buildtools/webpack.scss-loader',
}]
};

const htmlRule = {
test: /\.html$/,
use: 'ejs-loader',
};
const providePlugin = new webpack.ProvidePlugin({
// Make sure that Angular finds jQuery and does not fall back to jqLite
// See https://github.com/webpack/webpack/issues/582
'window.jQuery': 'jquery',
// For Bootstrap
'jQuery': 'jquery',
// For own scripts
$: 'jquery',
});

const svgRule = {
test: /\.svg$/,
use: [
{
loader: 'svg-inline-loader',
options: {
removeSVGTagAttrs: false,
},
const babelPresets = [[require.resolve('@babel/preset-env'), {
'targets': {
'browsers': ['last 2 versions', 'Firefox ESR', 'ie 11'],
},
'./buildtools/svg-viewbox-loader',
'svgo-loader',
]
};
'modules': false,
'loose': true,
}]];

function get_comp(firsts, lasts) {
return (f1, f2) => {
for (const pattern of firsts) {
if (f1.indexOf(pattern) >= 0) {
return -1;
}
if (f2.indexOf(pattern) >= 0) {
return 1;
}
const angularRule = {
test: require.resolve('angular'),
use: {
loader: 'expose-loader',
options: 'angular'
}
for (const pattern of lasts) {
if (f1.indexOf(pattern) >= 0) {
return 1;
}
if (f2.indexOf(pattern) >= 0) {
return -1;
}
};

// Expose corejs-typeahead as window.Bloodhound
const typeaheadRule = {
test: require.resolve('corejs-typeahead'),
use: {
loader: 'expose-loader',
options: 'Bloodhound'
}
return 0;
};
}

module.exports = function() {
const cssRule = {
test: /\.css$/,
use: [
'./buildtools/webpack.scss-loader',
'extract-loader',
'css-loader',
]
};

const sassRule = {
test: /\.scss$/,
use: [{
loader: './buildtools/webpack.scss-loader',
}]
};

const htmlRule = {
test: /\.html$/,
use: 'ejs-loader',
};

const svgRule = {
test: /\.svg$/,
use: [
{
loader: 'svg-inline-loader',
options: {
removeSVGTagAttrs: false,
},
},
'./buildtools/svg-viewbox-loader',
'svgo-loader',
]
};

function get_comp(firsts, lasts) {
return (f1, f2) => {
for (const pattern of firsts) {
if (f1.indexOf(pattern) >= 0) {
return -1;
}
if (f2.indexOf(pattern) >= 0) {
return 1;
}
}
for (const pattern of lasts) {
if (f1.indexOf(pattern) >= 0) {
return 1;
}
if (f2.indexOf(pattern) >= 0) {
return -1;
}
}
return 0;
};
}


const ngeoRule = {
test: /\/ngeo\/(?!node_modules\/).*\.js$/,
Expand Down
1 change: 1 addition & 0 deletions buildtools/webpack.config.dll.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ module.exports = {
sourceMap: true,
}),
],
sideEffects: false,
},
};
2 changes: 1 addition & 1 deletion contribs/gmf/apps/desktop/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
</gmf-profile>
</footer>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6,default-3.6,Array.prototype.includes,Object.entries,Object.values"></script>
<script src="/dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<script src="../../../dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/apps/desktop_alt/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
</footer>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6,default-3.6,Array.prototype.includes,Object.entries,Object.values"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3&key=AIzaSyA3NVIy-HOYT0a0CkChA6nFwqEFqHYWBVk"></script>
<script src="/dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<script src="../../../dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/apps/mobile/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
</div>
</ngeo-modal>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6,default-3.6,Array.prototype.includes,Object.entries,Object.values"></script>
<script src="/dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<script src="../../../dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/apps/mobile_alt/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
</gmf-authentication>
</nav>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6,default-3.6,Array.prototype.includes,Object.entries,Object.values"></script>
<script src="/dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<script src="../../../dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/apps/oeedit/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
</gmf-profile>
</footer>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6,default-3.6,Array.prototype.includes,Object.entries,Object.values"></script>
<script src="/dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<script src="../../../dist/vendor.js?${htmlWebpackPlugin.options.vars.version}"></script>
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
Expand Down
7 changes: 6 additions & 1 deletion karma-conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path');
const webpackMerge = require('webpack-merge');

const webpackConfig = webpackMerge(
Expand All @@ -21,7 +22,11 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
'test/spec/all.js',
{
pattern: path.resolve(__dirname, 'dist/vendor.js'),
watched: false,
served: true
}, 'test/spec/all.js',
],

// preprocess matching files before serving them to the browser
Expand Down