Skip to content

Commit e65b882

Browse files
James Zetlendevpatil7
authored andcommitted
feat: remove esm mid-compilation and add babel preset (magento#1404)
* feat: remove esm mid-compilation and add babel preset * fixup babel circular dep * chore: update zeit to node 10 * fixup venia calls buildpack by path * refactor: remove buildpack build * fixup remove CI cache rule * fixup exclude babel preset in babel build * Update pwa-devdocs/scripts/create-reference-docs/config/peregrine/index.js Co-Authored-By: James Calcaben <[email protected]> * fixup now deploy new upward file * fix: fix now.json to a version
1 parent 98eb578 commit e65b882

File tree

182 files changed

+303
-651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+303
-651
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
__fixtures__
33
# Minified build assets
44
dist
5-
# Babelified ES modules for NPM dependents
6-
esm
75
# Devdocs is a separate project
86
pwa-devdocs

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ lerna-debug.log
1414
.env
1515
yarn-error.log
1616
# Packages that build partially transpiled ES modules put them here
17-
packages/*/esm/*
1817
docker/certs

.nowignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
node_modules
22
dist
33
coverage
4-
esm
54
pwa-devdocs
65
storybook*
76
__test*

.prettierignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ coverage
33
# Minified build assets
44
dist
55
storybook-dist
6-
# Babelified ES modules for NPM dependents
7-
esm
86
# Devdocs is a separate project
97
pwa-devdocs
108

Dockerfile.dev

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ RUN apk --no-cache --virtual add \
1111
python \
1212
make \
1313
g++ \
14-
yarn
14+
yarn
1515

1616
# copy just the dependency files and configs needed for install
17+
COPY packages/babel-preset-peregrine/package.json ./packages/babel-preset-peregrine/package.json
18+
COPY packages/graphql-cli-validate-magento-pwa-queries/package.json ./packages/graphql-cli-validate-magento-pwa-queries/package.json
1719
COPY packages/peregrine/package.json ./packages/peregrine/package.json
1820
COPY packages/pwa-buildpack/package.json ./packages/pwa-buildpack/package.json
1921
COPY packages/upward-js/package.json ./packages/upward-js/package.json
2022
COPY packages/upward-spec/package.json ./packages/upward-spec/package.json
2123
COPY packages/venia-concept/package.json ./packages/venia-concept/package.json
22-
COPY package.json yarn.lock babel.config.js browserslist.js magento-compatibility.js ./
24+
COPY package.json yarn.lock babel.config.js magento-compatibility.js ./
2325

2426
# install dependencies with yarn
2527
RUN yarn install --frozen-lockfile
@@ -36,7 +38,7 @@ COPY ${ENVFILEPATH} ./packages/venia-concept/.env
3638
RUN yarn install --frozen-lockfile
3739

3840
# build the app
39-
RUN yarn run build
41+
RUN yarn run build
4042

4143
# MULTI-STAGE BUILD
4244
FROM node:10.14.1-alpine

Dockerfile.prod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ RUN apk --no-cache --virtual add \
1010
yarn
1111

1212
# copy just the dependency files and configs needed for install
13+
COPY packages/babel-preset-peregrine/package.json ./packages/babel-preset-peregrine/package.json
14+
COPY packages/graphql-cli-validate-magento-pwa-queries/package.json ./packages/graphql-cli-validate-magento-pwa-queries/package.json
1315
COPY packages/peregrine/package.json ./packages/peregrine/package.json
1416
COPY packages/pwa-buildpack/package.json ./packages/pwa-buildpack/package.json
1517
COPY packages/upward-js/package.json ./packages/upward-js/package.json
1618
COPY packages/upward-spec/package.json ./packages/upward-spec/package.json
1719
COPY packages/venia-concept/package.json ./packages/venia-concept/package.json
18-
COPY package.json yarn.lock babel.config.js browserslist.js magento-compatibility.js ./
20+
COPY package.json yarn.lock babel.config.js magento-compatibility.js ./
1921

2022
# install dependencies with yarn
2123
RUN yarn install --frozen-lockfile

babel.config.js

Lines changed: 9 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,11 @@
1-
const browsers = require('./browserslist');
2-
const plugins = [
3-
['@babel/plugin-proposal-class-properties'],
4-
['@babel/plugin-proposal-object-rest-spread'],
5-
['@babel/plugin-syntax-dynamic-import'],
6-
['@babel/plugin-syntax-jsx'],
7-
['@babel/plugin-transform-react-jsx'],
8-
['babel-plugin-graphql-tag']
9-
];
10-
11-
const targets = {
12-
dev: 'last 2 Chrome versions',
13-
prod: browsers,
14-
test: 'node 10'
15-
};
16-
17-
const config = api => {
18-
const envConfigs = {
19-
/**
20-
* Watch mode and build:esm partial transpilation mode.
21-
* The module-resolver plugin makes Babel recognize import paths from
22-
* package root, like 'src/classify'.
23-
*
24-
* BUT VENIA SHOULD NOT USE THEM, because it makes Venia less portable
25-
* and Venia should be more portable than an average PWA Studio app.
26-
*/
27-
development: {
28-
// Ignore everything with underscores except stories
29-
ignore: [/\/__(tests?|mocks|fixtures|helpers|dist)__\//],
30-
plugins: [
31-
...plugins,
32-
[
33-
'module-resolver',
34-
{
35-
root: ['./'],
36-
/**
37-
* Exported modules will be consumed by other projects
38-
* which import Venia. Those projects will need to
39-
* override the 'src/drivers' dependency so Venia
40-
* modules will run outside the Venia app. This alias
41-
* exports the modules so the drivers dependency is
42-
* a unique string '@magento/venia-drivers', which is
43-
* less likely to collide with an existing dependency
44-
* than 'src/drivers' is.
45-
*
46-
* In webpack (or any build system) config for a project
47-
* using Venia modules, you must write an override for
48-
* '@magento/venia-drivers' and make an alias to that
49-
* module in your build configuration, e.g.:
50-
*
51-
* alias: {
52-
* '@magento/venia-drivers': './src/veniaDrivers'
53-
* }
54-
*
55-
* to map from this virtual string to your replacement.
56-
*/
57-
alias: {
58-
'^src/drivers$': '@magento/venia-drivers'
59-
},
60-
/**
61-
* Suppress console warning about missing dependencies.
62-
*/
63-
loglevel: 'silent'
64-
}
65-
]
66-
],
67-
presets: [
68-
['@babel/preset-env', { modules: false, targets: targets.dev }]
69-
]
70-
},
71-
production: {
72-
plugins: [
73-
...plugins,
74-
[
75-
'@babel/plugin-transform-runtime',
76-
{ helpers: true, regenerator: true }
77-
]
78-
],
79-
presets: [
80-
['@babel/preset-env', { modules: false, targets: targets.prod }]
81-
]
82-
},
83-
test: {
84-
plugins: [...plugins, ['babel-plugin-dynamic-import-node']],
85-
presets: [
86-
[
87-
'@babel/preset-env',
88-
{ modules: 'commonjs', targets: targets.test }
89-
]
90-
]
91-
}
1+
module.exports = api => {
2+
const config = {
3+
presets: ['@magento/peregrine'],
4+
exclude: [/packages\/babel\-preset\-peregrine\//]
925
};
93-
return envConfigs[api.env() || 'development'];
6+
if (api.env() === 'development') {
7+
// Ignore everything with underscores except stories in dev mode
8+
config.exclude.push(/\/__(tests?|mocks|fixtures|helpers|dist)__\//);
9+
}
10+
return config;
9411
};
95-
96-
module.exports = config;

docker-compose.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ services:
2929
# this enables hot reloading from the container to detect changes made on the host file system
3030
volumes:
3131
- ./packages/peregrine/.storybook:/usr/src/app/packages/peregrine/.storybook:rw
32-
- ./packages/peregrine/esm:/usr/src/app/packages/peregrine/esm:rw
3332
- ./packages/peregrine/scripts:/usr/src/app/packages/peregrine/scripts:rw
34-
- ./packages/peregrine/src:/usr/src/app/packages/peregrine/src:rw
35-
- ./packages/pwa-buildpack/src:/usr/src/app/packages/pwa-buildpack/src:rw
33+
- ./packages/peregrine/lib:/usr/src/app/packages/peregrine/lib:rw
34+
- ./packages/pwa-buildpack/lib:/usr/src/app/packages/pwa-buildpack/lib:rw
3635
- ./packages/upward-js/lib:/usr/src/app/packages/upward-js/lib:rw
3736
- ./packages/venia-concept/.storybook:/usr/src/app/packages/venia-concept/.storybook:rw
38-
- ./packages/venia-concept/esm:/usr/src/app/packages/venia-concept/esm:rw
3937
- ./packages/venia-concept/src:/usr/src/app/packages/venia-concept/src:rw
4038
- ./packages/venia-concept/static:/usr/src/app/packages/venia-concept/static:rw
4139
links:

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ const jestConfig = {
163163
// Don't look for test files in these directories.
164164
testPathIgnorePatterns: [
165165
'dist',
166-
'esm',
167166
'node_modules',
168167
'__fixtures__',
169168
'__helpers__',

now.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
"includeFiles": [
2727
"package.json",
2828
".env",
29-
"venia-upward.yml",
29+
"upward.yml",
3030
"static/*",
3131
"templates/*"
3232
],
3333
"maxLambdaSize": "20mb"
3434
},
3535
"src": "packages/venia-concept/server-lambda.js",
36-
"use": "@now/node"
36+
"use": "@now/node@0.11.1"
3737
}
3838
],
3939
"routes": [

0 commit comments

Comments
 (0)