@@ -318,6 +318,22 @@ describe('Functional tests using webpack', function() {
318
318
} ) ;
319
319
} ) ;
320
320
321
+ it ( '.mjs files are supported natively' , ( done ) => {
322
+ const config = createWebpackConfig ( 'web/build' , 'dev' ) ;
323
+ config . addEntry ( 'main' , './js/hello_world' ) ;
324
+ config . setPublicPath ( '/build' ) ;
325
+
326
+ testSetup . runWebpack ( config , ( webpackAssert ) => {
327
+ // check that main.js has the correct contents
328
+ webpackAssert . assertOutputFileContains (
329
+ 'main.js' ,
330
+ 'Hello World!'
331
+ ) ;
332
+
333
+ done ( ) ;
334
+ } ) ;
335
+ } ) ;
336
+
321
337
describe ( 'addStyleEntry .js files are removed' , ( ) => {
322
338
it ( 'Without versioning' , ( done ) => {
323
339
const config = createWebpackConfig ( 'web' , 'dev' ) ;
@@ -1628,7 +1644,7 @@ module.exports = {
1628
1644
} ) ;
1629
1645
} ) ;
1630
1646
1631
- describe ( 'entrypoints.json' , ( ) => {
1647
+ describe ( 'entrypoints.json & splitChunks() ' , ( ) => {
1632
1648
it ( 'Use "all" splitChunks & look at entrypoints.json' , ( done ) => {
1633
1649
const config = createWebpackConfig ( 'web/build' , 'dev' ) ;
1634
1650
config . addEntry ( 'main' , [ './css/roboto_font.css' , './js/no_require' , 'vue' ] ) ;
@@ -1809,19 +1825,45 @@ module.exports = {
1809
1825
} ) ;
1810
1826
} ) ;
1811
1827
1812
- it ( '.mjs files are supported natively' , ( done ) => {
1813
- const config = createWebpackConfig ( 'web/build' , 'dev' ) ;
1814
- config . addEntry ( 'main' , './js/hello_world' ) ;
1815
- config . setPublicPath ( '/build' ) ;
1828
+ it ( 'Make sure chunkIds do not change between builds' , ( done ) => {
1829
+ // https://github.com/symfony/webpack-encore/issues/461
1830
+ const createSimilarConfig = function ( includeExtraEntry ) {
1831
+ const config = createWebpackConfig ( 'web/build' , 'production' ) ;
1832
+ config . addEntry ( 'main1' , './js/code_splitting' ) ;
1833
+ if ( includeExtraEntry ) {
1834
+ config . addEntry ( 'main2' , './js/eslint' ) ;
1835
+ }
1836
+ config . addEntry ( 'main3' , './js/no_require' ) ;
1837
+ config . setPublicPath ( '/build' ) ;
1816
1838
1817
- testSetup . runWebpack ( config , ( webpackAssert ) => {
1818
- // check that main.js has the correct contents
1819
- webpackAssert . assertOutputFileContains (
1820
- 'main.js' ,
1821
- 'Hello World!'
1822
- ) ;
1839
+ return config ;
1840
+ } ;
1823
1841
1824
- done ( ) ;
1842
+ const getMain3Contents = function ( config ) {
1843
+ const fullPath = path . join ( config . outputPath , 'main3.js' ) ;
1844
+
1845
+ if ( ! fs . existsSync ( fullPath ) ) {
1846
+ throw new Error ( 'Output file "main3.js" does not exist.' ) ;
1847
+ }
1848
+
1849
+ return fs . readFileSync ( fullPath , 'utf8' ) ;
1850
+ } ;
1851
+
1852
+ const configA = createSimilarConfig ( false ) ;
1853
+ const configB = createSimilarConfig ( true ) ;
1854
+
1855
+ testSetup . runWebpack ( configA , ( ) => {
1856
+ const main3Contents = getMain3Contents ( configA ) ;
1857
+
1858
+ testSetup . runWebpack ( configB , ( ) => {
1859
+ const finalMain3Contents = getMain3Contents ( configB ) ;
1860
+
1861
+ if ( finalMain3Contents !== main3Contents ) {
1862
+ throw new Error ( `Contents after first compile do not match after second compile: \n\n ${ main3Contents } \n\n versus \n\n ${ finalMain3Contents } \n` ) ;
1863
+ }
1864
+
1865
+ done ( ) ;
1866
+ } ) ;
1825
1867
} ) ;
1826
1868
} ) ;
1827
1869
} ) ;
0 commit comments