-
Notifications
You must be signed in to change notification settings - Fork 3
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
STRWEB-69: Add support for transpilation #73
Changes from 43 commits
312b8d4
9a6e70f
b3f46db
147556c
f3c0be7
f489da9
08e7e4a
164e4e1
9bc97b2
0865cf3
96a7752
bf2d685
36088b7
cdd84ed
afc0047
cb94f8e
bb7c220
789051c
79aad19
18400ec
6525b6d
0f6b317
453d42a
93fc9d8
18b02d2
3eb901a
1e9ea48
575250f
205cd93
ea0a1e1
fbe69a7
937663b
8ea65dd
1877c08
11955af
f4e5bab
b59901b
0fbb250
96e92ec
0fca9ff
9f380b4
41c4ce9
09096b1
9c9c981
6033b23
12f4b4e
1dcc971
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// The list of the default externals | ||
// https://webpack.js.org/configuration/externals/ | ||
const defaultExternals = [ | ||
'@folio/stripes', | ||
'@folio/stripes-components', | ||
'@folio/stripes-connect', | ||
'@folio/stripes-core', | ||
'@folio/stripes-util', | ||
'@folio/stripes-form', | ||
'@folio/stripes-final-form', | ||
'@folio/stripes-logger', | ||
'@folio/stripes-smart-components', | ||
'final-form', | ||
'final-form-arrays', | ||
'moment', | ||
'moment-timezone', | ||
'react', | ||
'react-dom', | ||
'react-final-form', | ||
'react-final-form-arrays', | ||
'react-final-form-listeners', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as |
||
'react-intl', | ||
'react-query', | ||
'react-redux', | ||
'react-router', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add |
||
'redux', | ||
'stripes-config', | ||
]; | ||
|
||
module.exports = { | ||
defaultExternals, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const path = require('path'); | ||
const postCssImport = require('postcss-import'); | ||
const autoprefixer = require('autoprefixer'); | ||
const postCssCustomProperties = require('postcss-custom-properties'); | ||
const postCssCalc = require('postcss-calc'); | ||
const postCssNesting = require('postcss-nesting'); | ||
const postCssCustomMedia = require('postcss-custom-media'); | ||
const postCssMediaMinMax = require('postcss-media-minmax'); | ||
const postCssColorFunction = require('postcss-color-function'); | ||
|
||
const { generateStripesAlias, tryResolve } = require('./webpack/module-paths'); | ||
|
||
const locateCssVariables = () => { | ||
const variables = 'lib/variables.css'; | ||
const localPath = path.join(path.resolve(), variables); | ||
|
||
// check if variables are present locally (in cases when stripes-components is | ||
// being built directly) if not look for them via stripes aliases | ||
return tryResolve(localPath) ? | ||
localPath : | ||
path.join(generateStripesAlias('@folio/stripes-components'), variables); | ||
}; | ||
|
||
module.exports = { | ||
plugins: [ | ||
postCssImport(), | ||
autoprefixer(), | ||
postCssCustomProperties({ | ||
preserve: false, | ||
importFrom: [locateCssVariables()], | ||
disableDeprecationNotice: true | ||
}), | ||
postCssCalc(), | ||
postCssNesting(), | ||
postCssCustomMedia(), | ||
postCssMediaMinMax(), | ||
postCssColorFunction(), | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
const expect = require('chai').expect; | ||
const babelLoaderRule = require('../../webpack/babel-loader-rule'); | ||
|
||
describe('The babel-loader-rule', function () { | ||
describe.only('The babel-loader-rule', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. omit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zburke thank you for catching this! |
||
describe('test condition function', function () { | ||
beforeEach(function () { | ||
this.sut = babelLoaderRule({ modules: {} }).test; | ||
this.sut = babelLoaderRule(['@folio/inventory']); | ||
}); | ||
|
||
it('selects files for @folio scoped node_modules', function () { | ||
const fileName = '/projects/folio/folio-testing-platform/node_modules/@folio/inventory/index.js'; | ||
const result = this.sut(fileName); | ||
const fileName = '/projects/folio/folio-testing-platform/node_modules/stripes-config'; | ||
const result = this.sut.include(fileName); | ||
expect(result).to.equal(true); | ||
}); | ||
|
||
it('does not select node_modules files outside of @folio scope', function () { | ||
const fileName = '/projects/folio/folio-testing-platform/node_modules/lodash/lodash.js'; | ||
const result = this.sut(fileName); | ||
const result = this.sut.include(fileName); | ||
expect(result).to.equal(false); | ||
}); | ||
|
||
it('only selects .js file extensions', function () { | ||
const fileName = '/project/folio/folio-testing-platform/node_modules/@folio/search/package.json'; | ||
const result = this.sut(fileName); | ||
expect(result).to.equal(false); | ||
const result = fileName.match(this.sut.test); | ||
expect(result).to.equal(null); | ||
}); | ||
|
||
it('selects files outside of both @folio scope and node_modules', function () { | ||
// This test case would hold true for yarn-linked modules, @folio scoped or otherwise | ||
// Therefore this implies that we are not yarn-linking any non-@folio scoped modules | ||
const fileName = '/projects/folio/stripes-core/src/configureLogger.js'; | ||
const result = this.sut(fileName); | ||
const result = this.sut.include(fileName); | ||
expect(result).to.equal(true); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moment-timezone
isn't currently provided by the platform for apps use as a peer-dep but I think it needs to be for this to work correctly. After this PR, it would be extern'ed in apps but also never pulled in by the platform, and thus absent in the final bundle. (Right?)